[K12OSN] Script for checking if servers are up.
Nils Breunese
nils at breun.nl
Thu Oct 18 21:05:55 UTC 2007
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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: Dit deel van het bericht is digitaal ondertekend
URL: <http://listman.redhat.com/archives/k12osn/attachments/20071018/b7332af2/attachment.sig>
More information about the K12OSN
mailing list