Adding notify-by-ntfy.sh to send things through personal EWG server
parent
f53198198d
commit
1383430da0
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
notify_host="https://notify.everwatch.global"
|
||||||
|
channel="EWG"
|
||||||
|
alertType=""
|
||||||
|
msgTitle=""
|
||||||
|
message=""
|
||||||
|
tag="exclamation"
|
||||||
|
priority="3"
|
||||||
|
state=""
|
||||||
|
|
||||||
|
case "$NAGIOS_NOTIFICATIONTYPE" in
|
||||||
|
PROBLEM) tag="bangbang";;
|
||||||
|
RECOVERY) tag="ok";;
|
||||||
|
ACKNOWLEDGEMENT) tag="ok_hand";;
|
||||||
|
FLAPPINGSTART) tag="hatched_chick";;
|
||||||
|
FLAPPINGSTOP) tag="hourglass_flowing_sand";;
|
||||||
|
DOWNTIMESTART) tag="sleeping_bed";;
|
||||||
|
DOWNTIMEEND) tag="sunny";;
|
||||||
|
*) tag="exclamation";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
do_notify() {
|
||||||
|
[ -n "$1" ] && channel="${channel}-${1}"
|
||||||
|
curl -s \
|
||||||
|
-H "Title: ${msgTitle}" \
|
||||||
|
-H "Tags: ${tag}" \
|
||||||
|
-H "Priority: ${priority}" \
|
||||||
|
-d "${message}" \
|
||||||
|
${notify_host}/${channel}
|
||||||
|
}
|
||||||
|
|
||||||
|
do_host() {
|
||||||
|
msgTitle="HOST ${NAGIOS_NOTIFICATIONTYPE}"
|
||||||
|
message="$NAGIOS_NOTIFICATIONTYPE $NAGIOS_HOSTNAME is $NAGIOS_HOSTSTATE $NAGIOS_LONGDATETIME"
|
||||||
|
do_notify "Hosts"
|
||||||
|
}
|
||||||
|
|
||||||
|
do_service() {
|
||||||
|
msgTitle="SERVICE ${NAGIOS_NOTIFICATIONTYPE}"
|
||||||
|
message="$NAGIOS_NOTIFICATIONTYPE $NAGIOS_SERVICEDESC @ $NAGIOS_HOSTALIAS is $NAGIOS_SERVICESTATE $NAGIOS_LONGDATETIME"
|
||||||
|
do_notify "Services"
|
||||||
|
}
|
||||||
|
|
||||||
|
while [ -n "$1" ]; do
|
||||||
|
case "$1" in
|
||||||
|
-t|--type) alertType="$2"; shift 2;;
|
||||||
|
*) shift 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$alertType" in
|
||||||
|
h|host|host) do_host;;
|
||||||
|
s|svc|service) do_service;;
|
||||||
|
*) shift 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit
|
||||||
Loading…
Reference in New Issue