Nagios: Only send notification when all 4 host are down

dependenciesfibernagios

As part of a larger complex, is a small office building with 4 computers. It has a single cat5 run to a non-managed switch that has 4 computers connected to it.

Since I can't ping the switch, the only way I can tell if that network is up is by pinging the computers. But the ladies in that office tend to turn the computers off on holidays, weekend, when they fell like it, etc. 99% of the time, at least 1 computer is on.

What I want to do is have Nagios send a notification only if all 4 computers go missing. Aka, the switch died or a FSB (fiber seeking backhoe) had some fun in the area. I don't think Nagios host check dependencies will do this from what I have been reading.

Any other way to do this?

Best Answer

Writing your own small plugin that does this shouldn't be too difficult, as simple test plugins are really easy to write, all they have to do is to return an exit code and a line of text that nagios interprets (see the doc).

Edit: I had a minute of time, so here is an extremely simple example on how to go for such a test:

#!/bin/bash

ping -c 3 host1 > /dev/null        
if [ "$?" -eq "0" ]; then
   echo "OK - answer from host1"
   exit 0
fi

ping -c 3 host2 > /dev/null        
if [ "$?" -eq "0" ]; then
   echo "OK - answer from host2"
   exit 0
fi

echo "Fail - no host answers"
exit 2

This will simply send three pings to the hosts and exit with a return value of 0 if a host answers and finally exit with a value of 2 if none could be reached.