Updated to include service definition without auto macros enabled in nagios.cfg
This commit is contained in:
Regular → Executable
+21
-8
@@ -10,6 +10,27 @@ priority="3"
|
||||
state=""
|
||||
testMode=""
|
||||
|
||||
### Define command for service
|
||||
### define command {
|
||||
### command_name notify-service-by-ntfy
|
||||
### command_line $USER1$/notify-by-ntfy.sh -t service -ha "$HOSTALIAS$" -h "$HOSTNAME$" -hs "$HOSTSTATE$" -ld "$LONGDATETIME$" -nt "$NOTIFICATIONTYPE$" -s "$SERVICEDESC$" -ss "$SERVICESTATE$"
|
||||
### }
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
--test) testMode="true"; shift 1;;
|
||||
-t|--type) alertType="$2"; shift 2;;
|
||||
-ha) NAGIOS_HOSTALIAS="$2"; shift 2;;
|
||||
-h) NAGIOS_HOSTNAME="$2"; shift 2;;
|
||||
-hs) NAGIOS_HOSTSTATE="$2"; shift 2;;
|
||||
-ld) NAGIOS_LONGDATETIME="$2"; shift 2;;
|
||||
-nt) NAGIOS_NOTIFICATIONTYPE="$2"; shift 2;;
|
||||
-s) NAGIOS_SERVICEDESC="$2"; shift 2;;
|
||||
-ss) NAGIOS_SERVICESTATE="$2"; shift 2;;
|
||||
*) shift 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$NAGIOS_NOTIFICATIONTYPE" in
|
||||
PROBLEM) tag="bangbang";;
|
||||
RECOVERY) tag="ok";;
|
||||
@@ -43,14 +64,6 @@ do_service() {
|
||||
do_notify "Services"
|
||||
}
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-t|--type) alertType="$2"; shift 2;;
|
||||
--test) testMode="true"; shift 1;;
|
||||
*) shift 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$testMode" ]; then
|
||||
NAGIOS_NOTIFICATIONTYPE="Test"
|
||||
NAGIOS_HOSTNAME="FakeHost"
|
||||
|
||||
Reference in New Issue
Block a user