diff options
Diffstat (limited to 'src/health/notifications')
-rwxr-xr-x | src/health/notifications/alarm-notify.sh.in | 21 | ||||
-rwxr-xr-x | src/health/notifications/health_alarm_notify.conf | 1 | ||||
-rw-r--r-- | src/health/notifications/telegram/README.md | 2 | ||||
-rw-r--r-- | src/health/notifications/telegram/metadata.yaml | 2 |
4 files changed, 19 insertions, 7 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 diff --git a/src/health/notifications/health_alarm_notify.conf b/src/health/notifications/health_alarm_notify.conf index f3b67c9de..9dcec27ae 100755 --- a/src/health/notifications/health_alarm_notify.conf +++ b/src/health/notifications/health_alarm_notify.conf @@ -413,6 +413,7 @@ DEFAULT_RECIPIENT_KAVENEGAR="" # multiple recipients can be given like this: # "CHAT_ID_1 CHAT_ID_2 ..." +# To send alerts to a specific topic within a chat, use `CHAT_ID:TOPIC_ID`. # enable/disable sending telegram messages SEND_TELEGRAM="YES" diff --git a/src/health/notifications/telegram/README.md b/src/health/notifications/telegram/README.md index e263d0bb5..90cca4214 100644 --- a/src/health/notifications/telegram/README.md +++ b/src/health/notifications/telegram/README.md @@ -55,7 +55,7 @@ The following options can be defined for this notification |:----|:-----------|:-------|:--------:| | SEND_TELEGRAM | Set `SEND_TELEGRAM` to YES | YES | yes | | TELEGRAM_BOT_TOKEN | set `TELEGRAM_BOT_TOKEN` to your bot token. | | yes | -| DEFAULT_RECIPIENT_TELEGRAM | Set `DEFAULT_RECIPIENT_TELEGRAM` to the chat ID you want the alert notifications to be sent to. You can define multiple chat IDs like this: -49999333322 -1009999222255. | | yes | +| DEFAULT_RECIPIENT_TELEGRAM | Set the `DEFAULT_RECIPIENT_TELEGRAM` variable in your config file to your Telegram chat ID (find it with @myidbot). Separate multiple chat IDs with spaces. To send alerts to a specific topic within a chat, use `chatID:topicID`. | | yes | ##### DEFAULT_RECIPIENT_TELEGRAM diff --git a/src/health/notifications/telegram/metadata.yaml b/src/health/notifications/telegram/metadata.yaml index cc6d8c91e..daa45da72 100644 --- a/src/health/notifications/telegram/metadata.yaml +++ b/src/health/notifications/telegram/metadata.yaml @@ -40,7 +40,7 @@ required: true - name: 'DEFAULT_RECIPIENT_TELEGRAM' default_value: '' - description: "Set `DEFAULT_RECIPIENT_TELEGRAM` to the chat ID you want the alert notifications to be sent to. You can define multiple chat IDs like this: -49999333322 -1009999222255." + description: "Set the `DEFAULT_RECIPIENT_TELEGRAM` variable in your config file to your Telegram chat ID (find it with @myidbot). Separate multiple chat IDs with spaces. To send alerts to a specific topic within a chat, use `chatID:topicID`." required: true detailed_description: | All roles will default to this variable if left unconfigured. |