]> arthur.barton.de Git - netdata.git/blobdiff - plugins.d/alarm-notify.sh
alarm-notify.sh configuration; alarm-notify.sh support multiple recipients per alarm...
[netdata.git] / plugins.d / alarm-notify.sh
index 9188b9671261e8258bd12b4bd0f25400fb9fa6a0..55d149a5d1b91e97287fc97bb22450ebd8292b48 100755 (executable)
@@ -195,27 +195,31 @@ send_email() {
 # pushover sender
 
 send_pushover() {
-    local apptoken="${1}" usertoken="${2}" title="${3}" message="${4}" httpcode
+    local apptoken="${1}" usertoken="${2}" title="${3}" message="${4}" httpcode sent=0 user
 
     if [ "${SEND_PUSHOVER}" = "YES" -a ! -z "${apptoken}" -a ! -z "${usertoken}" -a ! -z "${title}" -a ! -z "${message}" ]
         then
 
-        httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
-            --form-string "token=${apptoken}" \
-            --form-string "user=${usertoken}" \
-            --form-string "html=1" \
-            --form-string "title=${title}" \
-            --form-string "message=${message}" \
-            https://api.pushover.net/1/messages.json)
-
-        if [ "${httpcode}" == "200" ]
-        then
-            echo >&2 "${me}: Sent notification push for ${status} on '${chart}.${name}'"
-            return 0
-        else
-            echo >&2 "${me}: FAILED to send notification push for ${status} on '${chart}.${name}' with HTTP error code ${httpcode}."
-            return 1
-        fi
+        for user in ${usertoken//,/ }
+        do
+            httpcode=$(${curl} --write-out %{http_code} --silent --output /dev/null \
+                --form-string "token=${apptoken}" \
+                --form-string "user=${user}" \
+                --form-string "html=1" \
+                --form-string "title=${title}" \
+                --form-string "message=${message}" \
+                https://api.pushover.net/1/messages.json)
+
+            if [ "${httpcode}" == "200" ]
+            then
+                echo >&2 "${me}: Sent notification push for ${status} on '${chart}.${name}' to '${user}'"
+                sent=$((sent + 1))
+            else
+                echo >&2 "${me}: FAILED to send notification push for ${status} on '${chart}.${name}' to '${user}' with HTTP error code ${httpcode}."
+            fi
+        done
+
+        [ ${sent} -gt 0 ] && return 0
     fi
 
     return 1