Page 2 of 2

Re: Nagios does not update status in the UI

Posted: Wed Oct 28, 2015 4:08 pm
by linuser
hsmith wrote:Quick example script. It's pretty hack-y, but hey, it does the thing.

Code: Select all

#!/bin/bash



S1="active"


Info=$(systemctl status $1 | awk 'NR==3' | awk '{print $2}')



if [ $Info == $S1 ]

then

        echo "yay" $1 "is running!"

        exit 0

else
        echo "boooo" $1 "is not running!"

        exit 3
fi
Ok. That did the trick. The only thing is if the service is down Nagios recognizes it as "Unknown/Amber" and not "Critical/Red". But yea I think that's good enough for now! 8-) Lets leave this thread open in-case anyone else has any suggestions or insights. Thanks so much for the help!

Re: Nagios does not update status in the UI

Posted: Wed Oct 28, 2015 4:11 pm
by hsmith
Have it exit with 2 instead of 3. Oops.

0 = Good
1 = Warning
2 = Critical
3 = Unknown

Re: Nagios does not update status in the UI

Posted: Wed Oct 28, 2015 4:14 pm
by linuser
Yep. Awesome man thanks again! We can close this out.

Re: Nagios does not update status in the UI

Posted: Wed Oct 28, 2015 4:15 pm
by rkennedy
Glad to see this worked out! I will now close this thread, but feel free to open another in the future if you need more assistance.