[K12OSN] Script for checking if servers are up.

Doug Simpson simpsond at leopards.k12.ar.us
Fri Oct 19 13:03:48 UTC 2007


Ultimately, the server running the script will use festival to speak the name of the down server and the time can be adjusted as needed.

The email was just being used for a test until I get it running. . . it would be annoying during testing for it to be speaking.

Doug

Doug Simpson
Technology Specialist
De Queen Public Schools
De Queen, AR
simpsond at leopards.k12.ar.us

>>> Nils Breunese <nils at breun.nl> 10/18/2007 4:05 PM >>>
Doug Simpson wrote:

> I am trying to make a script that will ping servers and if they are  
> down, send a message. If they are up it won't send a message.
>
> The problem I am having is if there are more than one, it won't work.
>
> Here is a sample of my script:
> **********sample begins below*************
> while (true)
> do
> sleep 30
> if ping -i 3 -c 3 192.168.0.222
> then
> continue
> else
> echo "192.168.0.222 down!" | mail -s "222 down" veewee77 at alltel.net 
> break
> fi
> done
> **********sample ends above***************

You realize that you'll be getting an email every 30 seconds if the  
ping is not succesful?

Instead of scripting something like this myself, I'd just install a  
simple monitoring tool like munin [0]. I was very pleasantly  
surprised by the easy setup of munin, because of the sane defaults it  
has for its included plugins. You yum install munin on one machine  
and yum install munin-node on all machines you want to monitor (might  
as well install munin-node on the munin machine too). You set the IP  
address of the munin machine in the config file for the nodes and  
right after enabling notifications you will automatically be emailed  
when one of the machines is under high load, is down, has high disk  
usage, etc. Plus munin also generates all kinds of pretty graphs for  
everything it monitors. I highly recommend it for simple monitoring.

ZABBIX, Nagios, ZenOSS et al are all really nice and flexible, but  
generally a much bigger PITA to setup.

Nils Breunese.

[0] http://munin.sourceforge.net/ 







More information about the K12OSN mailing list