OpsView/Nagios check for Blacknight.ie Status Page

As part of my placement, we monitor websites hosted by Blacknight.ie.

If Blacknight are having issues we tend to get alerts messages about "Connection Refused" which tend to cause some consternation!

To cut down on the amount of clicking, I've wrote a small bash script that can be run by OpsView/Nagios that will check the Blacknight Status Page and return a count of the number of times that the "NOTOK" image is shown!

 

If that number is more than one, Blacknight's servers are reporting problems!

#!/bin/bash
#
#       Nagios Check Plugin for Blacknight.ie
#       Displays message if Blacknight are having technical issues with any of their servers
#
NOTOK=`curl --silent "http://www.blacknightstatus.com/server_monitor.php" | grep -E "http://blacknightstatus.com/statusmon/images/notok.gif" | wc -l`

if [ "$NOTOK" -eq "0" ] ; then
{
echo "Plugin failure: Information not found, log incident with N&S";
exit 1;
}
elif [ "$NOTOK" -eq "1" ] ; then
{
echo "All OK";
exit 0;
}
elif [ "$NOTOK"  -ge "2" ] ; then
{
echo "Blacknight Status Page reporting issues";
exit 2;
}
else
{
echo "Plugin failure: Unexpected output!";
exit 2;
}
fi