Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Does the switch support SNMP? Some non-managed switches do, in which case you could monitor it that way. –  John Gardeniers Apr 3 '11 at 22:13

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
I didn't think of doing it that way, but this will work excellent. Thank you. –  Porch Apr 4 '11 at 1:24

Well, four machines make a cluster, no? See http://nagios.sourceforge.net/docs/nagioscore/3/en/clusters.html in the documentation for an indication on how to create an "OR" check; one that notifies only when several conditions occur.

share|improve this answer
    
check_cluster was the command I was looking for. Thank you. But SvenW below came up with a script that will make the job cleaner. –  Porch Apr 4 '11 at 1:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.