Page 1 of 1
Secondary Alerting on Primary Global Notification Status
Posted: Mon Mar 16, 2015 12:16 pm
by uidaho
I am researching methods to alert ourselves from our secondary Nagios XI server that our primary server's global notifications have been disabled for more than X amount of time. Any input, ideas, examples of what others have done would be greatly appreciated!
thank you,
Clint
Re: Secondary Alerting on Primary Global Notification Status
Posted: Mon Mar 16, 2015 12:59 pm
by abrist
Well, you could write a small script to call the json api and check the "enable_notifications" key. You may want to set a few retries on the check so that it only alerts when they have been disabled longer than the number of retries * the retry interval. I whipped up a quick script to do this:
check_notifications.sh:
Code: Select all
#/bin/bash
USERNAME="$1"
PASSWORD="$2"
SERVER="$3"
NOTIFY=$(curl -s http://$USERNAME:$PASSWORD@$SERVER/nagios/cgi-bin/statusjson.cgi?query=programstatus | grep "enable_notifications" | sed 's/.*: //' | sed s'/,//')
if [ "$NOTIFY" == "false" ]; then
echo "CRITICAL - Notifications on Nagios server $SERVER are disabled"
exit 2
elif [ "$NOTIFY" == "true" ]; then
echo "OK - Notifications on Nagios server $SERVER are enabled"
exit 0
else
echo "UNKNOWN - Notification state on server $SERVER could not be checked."
exit 3
fi
And you would run it like:
Code: Select all
./check_notifications.sh "<username>" "<password> "<nagios server>"
For example:
Code: Select all
[root@localhost libexec]# ./check_notifications.sh "nagiosadmin" "welcome" "localhost"
OK - Notifications on Nagios server localhost are enabled
Re: Secondary Alerting on Primary Global Notification Status
Posted: Mon Mar 16, 2015 5:58 pm
by Box293
I also believe the "Nagios XI Server" monitoring wizard has some similar functionality. Secondary can watch Primary and vice versa.