From 7ab0f58ec6dfd5fc11ef324c9890432500eea4e4 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 20 Jul 2020 22:04:57 +0200 Subject: [PATCH] Pushover: Soundeinstellungen eingebunden --- .../commands/pushover-notification.conf | 2 ++ .../scripts/pushover-host-notification.sh | 16 +++++++++++++ .../scripts/pushover-service-notification.sh | 24 ++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/notification/pushover/commands/pushover-notification.conf b/notification/pushover/commands/pushover-notification.conf index eb72f1c..1bfbbe7 100644 --- a/notification/pushover/commands/pushover-notification.conf +++ b/notification/pushover/commands/pushover-notification.conf @@ -47,6 +47,8 @@ object NotificationCommand "pushover-service-notification" { HOSTNAME = "$host.name$" SERVICENAME = "$service.name$" + SERVICEDISPLAYNAME = "$service.display_name$" + SERVICESTATE = "$service.state$" HOSTDISPLAYNAME = "$host.display_name$" SERVICESTATE = "$service.state$" SERVICEOUTPUT = "$service.output$" diff --git a/notification/pushover/scripts/pushover-host-notification.sh b/notification/pushover/scripts/pushover-host-notification.sh index 78bc688..6f43f88 100755 --- a/notification/pushover/scripts/pushover-host-notification.sh +++ b/notification/pushover/scripts/pushover-host-notification.sh @@ -39,6 +39,10 @@ ICINGA2HOST="$(hostname)" CURLPROXY="" debug="0" +UP_SOUND="pushover" +DOWN_SOUND="siren" +UNREACHABLE_SOUND="" + ##################################################### #Übergebene Parameter # @@ -100,6 +104,17 @@ then PUSHOVEREXPIRE="300" fi +#The host’s current state. Can be one of UNREACHABLE, UP and DOWN. +if [ "$HOSTSTATE" = "UP" ] +then + SOUND=$UP_SOUND +elif [ "$SERVICESTATE" = "DOWN" ] +then + SOUND=$DOWN_SOUND +elif [ "$SERVICESTATE" = "UNREACHABLE" ] +then + SOUND=$UNREACHABLE_SOUND +fi #Kommando, um per curl die Pushover-message zu verschicken failstate=$(curl \ @@ -109,6 +124,7 @@ failstate=$(curl \ --form-string "user=$PUSHOVERUSER" \ --form-string "message=$PUSHOVERMESSAGE" \ --form-string "title=$PUSHOVERTITLE" \ + --form-string "sound=$SOUND" \ --form-string "priority=$PUSHOVERPRIORITY" \ --form-string "retry=$PUSHOVERRETRY" \ --form-string "expire=$PUSHOVEREXPIRE" \ diff --git a/notification/pushover/scripts/pushover-service-notification.sh b/notification/pushover/scripts/pushover-service-notification.sh index ccada77..f4c208a 100755 --- a/notification/pushover/scripts/pushover-service-notification.sh +++ b/notification/pushover/scripts/pushover-service-notification.sh @@ -37,7 +37,12 @@ logpath="/var/log/pushover_icinga.txt" ICINGA2HOST="$(hostname)" CURLPROXY="" -debug="1" +debug="0" + +OK_SOUND="pushover" +WARNING_SOUND="intermission" +CRITICAL_SOUND="siren" +UNKNOWN_SOUND="" ##################################################### #Übergebene Parameter @@ -58,6 +63,8 @@ debug="1" # # HOSTNAME = "$host.name$" # SERVICENAME = "$service.name$" +# SERVICEDISPLAYNAME = "$service.display_name$" +# SERVICESTATE = "$service.state$" # HOSTDISPLAYNAME = "$host.display_name$" # SERVICESTATE = "$service.state$" # SERVICEOUTPUT = "$service.output$" @@ -102,6 +109,19 @@ then PUSHOVEREXPIRE="300" fi +#The service’s current state. Can be one of OK, WARNING, CRITICAL and UNKNOWN +if [ "$SERVICESTATE" = "OK" ] +then + SOUND=$OK_SOUND +elif [ "$SERVICESTATE" = "WARNING" ] +then + SOUND=$WARNING_SOUND +elif [ "$SERVICESTATE" = "CRITICAL" ] +then + SOUND=$CRITICAL_SOUND +else + SOUND="" +fi #Kommando, um per curl die Pushover-message zu verschicken failstate=$(curl \ @@ -111,6 +131,7 @@ failstate=$(curl \ --form-string "user=$PUSHOVERUSER" \ --form-string "message=$PUSHOVERMESSAGE" \ --form-string "title=$PUSHOVERTITLE" \ + --form-string "sound=$SOUND" \ --form-string "priority=$PUSHOVERPRIORITY" \ --form-string "retry=$PUSHOVERRETRY" \ --form-string "expire=$PUSHOVEREXPIRE" \ @@ -140,6 +161,7 @@ NOTIFICATIONAUTHOR: $NOTIFICATIONAUTHOR HOSTDISPLAYNAME: $HOSTDISPLAYNAME SERVICEDISPLAYNAME: $SERVICEDISPLAYNAME SERVICESTATE: $SERVICESTATE +SOUND: $SOUND ICINGALONGDATETIME: $ICINGALONGDATETIME ICINGA2HOST: $ICINGA2HOST SERVICEOUTPUT: $SERVICEOUTPUT