Nagios does not update status in the UI
Posted: Wed Oct 28, 2015 2:02 pm
On my remote system I am using the "check_init_service" script plugin to allow Nagios to capture the status of a service. I had to modify the script a bit to work within RHEL7 since it uses systemctl for starting services. Problem is now the nagios server is getting the data back and posting into the UI (see image) but it does not ever change the status, it stays green and 'OK' even if the service is down. I'd like this to change status if the service is down or it cant be checked for some reason. Here is the original script:
This is the part I changed:
So basically changed the /sbin/service line to use /bin/systemctl and only print out the 3rd line. The output shows up in the Nagios UI as seen in the image. And this is where the functionality pretty much stops. I need a way for the server to distinguish between states and update status appropriately. If the service is down I need a "Critical/Red" status and if the service cant be checked I need an "unknown/amber" status, etc...How can I do this?
Code: Select all
#!/bin/sh
PROGNAME=`basename $0`
print_usage() {
echo "Usage: $PROGNAME"
}
print_help() {
echo ""
print_usage
echo ""
echo "This plugin checks the status of services normally started by the init process."
echo ""
support
exit 0
}
case "$1" in
--help)
print_help
exit 0
;;
-h)
print_help
exit 0
;;
*)
if [ $# -eq 1 ]; then
/sbin/service $1 status
ret=$?
case "$ret" in
0)
exit $ret
;;
*)
exit 2
;;
esac
else
echo "ERROR: No service name specified on command line"
exit 3
fi
;;
esac
Code: Select all
if [ $# -eq 1 ]; then
/bin/systemctl status $1 | awk 'NR==3'
ret=$?
case "$ret" in