diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
commit | 87d772a7d708fec12f48cd8adc0dedff6e1025da (patch) | |
tree | 1fee344c64cc3f43074a01981e21126c8482a522 /src/health/notifications/alarm-notify.sh.in | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-87d772a7d708fec12f48cd8adc0dedff6e1025da.tar.xz netdata-87d772a7d708fec12f48cd8adc0dedff6e1025da.zip |
Adding upstream version 1.47.0.upstream/1.47.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/health/notifications/alarm-notify.sh.in')
-rwxr-xr-x | src/health/notifications/alarm-notify.sh.in | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/health/notifications/alarm-notify.sh.in b/src/health/notifications/alarm-notify.sh.in index 9a5780de1..c7c44cb11 100755 --- a/src/health/notifications/alarm-notify.sh.in +++ b/src/health/notifications/alarm-notify.sh.in @@ -641,8 +641,12 @@ filter_recipient_by_criticality() { ;; CLEAR) - # remove tracking file - [ -f "${tracking_file}" ] && rm "${tracking_file}" + if [ -f "${tracking_file}" ]; then + tracking_file_existed="yes" + rm "${tracking_file}" + else + tracking_file_existed="" + fi # "noclear" modifier set, block notification if [ "${mod_noclear}" == "1" ]; then @@ -657,7 +661,7 @@ filter_recipient_by_criticality() { fi # "critical" modifier set, send notification if tracking file exists - if [ "${mod_critical}" == "1" ] && [ -f "${tracking_file}" ]; then + if [ "${mod_critical}" == "1" ] && [ -n "${tracking_file_existed}" ]; then debug "SEVERITY FILTERING for ${recipient_arg} VIA ${method}: ALLOW: recipient has been notified for this alarm in the past (no status change will be sent from now)" return 0 fi @@ -1515,13 +1519,20 @@ send_telegram() { notify_telegram=1 notify_retries=${TELEGRAM_RETRIES_ON_LIMIT:-0} + IFS=":" read -r chatID threadID <<< "${chatid}" + + # https://core.telegram.org/bots/api#sendmessage + api_url="https://api.telegram.org/bot${bottoken}/sendMessage?chat_id=${chatID}" + if [ -n "${threadID}" ]; then + api_url+="&message_thread_id=${threadID}" + fi + while [ ${notify_telegram} -eq 1 ]; do - # https://core.telegram.org/bots/api#sendmessage httpcode=$(docurl ${disableNotification} \ --data-urlencode "parse_mode=HTML" \ --data-urlencode "disable_web_page_preview=true" \ --data-urlencode "text=${emoji} ${message}" \ - "https://api.telegram.org/bot${bottoken}/sendMessage?chat_id=${chatid}") + "${api_url}") notify_telegram=0 |