Menu
Index

Contact
LinkedIn
GitHub
Atom Feed
Comments Atom Feed



Tweet

Similar Articles

15/06/2011 09:34
Universal Log Analyser and snmpd extension scripts
22/12/2011 09:30
Peak Network Bandwidth for Cacti

Recent Articles

23/04/2017 14:21
Raspberry Pi SD Card Test
07/04/2017 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
28/03/2017 13:07
Kubernetes to learn Part 4
23/03/2017 16:09
Kubernetes to learn Part 3
21/03/2017 15:18
Kubernetes to learn Part 2

Glen Pitt-Pladdy :: Blog

Ping, ping, ping....

Update: This is an old version of the script. See a more recent version of the pinger script.

 

After searching high and low for a basic host monitoring utility capable of monitoring and logging ping status of a number of hosts, I gave up and wrote my own.

Keeping it simple

The big problem with everything I found was that it was way too complicated, or simply didn't do the job.

The original version of the script was written simply to log pings, and this week proved it's usefulness once again, but this time it needed a small addition.

A company I do IT consulting for ran into some trouble (BT fault) with their internet connectivity. Their connection is intermittent (mostly down), so to ensure they get their mail reliably, the backup MX needs to deliver the queued mail as soon as their connection comes up rather than on the regular retry schedule which could be too slow to catch them when they come up briefly.

All that I added was the facility to execute commands when a host goes down or comes up, and by executing "/usr/sbin/sendmail -q" with postfix, it gives it a kick and it attempts to deliver the queue. Likewise this could be used to email someone when a host's status changes.

The next day, the script proved useful again at another company where I had it running to log the status of their networks (I didn't trust some of their service providers). A hosting company sent a mail saying that they had detected a problem with the server in the data centre, but wanted payment before they would say what the problem was. A quick look at logs that this script produces and it was all clear (I monitor the last couple of hops as well as the server): one of their routers had died for a few minutes and hence the server was not available. Why they wanted to be paid to tell us that they had a fault (they probably would not have admitted it anyway), really calls into question their own monitoring (never attribute to malice what can be attributed to stupidity).

How to use it

Simply fill in a useful name (put into the column headers of the logs) and associated hostname or IP address in the %MONITOR hash.

Next, if you want some action when a host goes up or down, add that into the %HOST_UP or %HOST_DOWN hashes.

If you want control over the rates and other parameters of ping, then alter them below.

The script is normally run on Debian GNU/Linux, but should be fine on virtually any other Linux distro, and also most other unix style systems. You may need to modify the path to Perl or ping, and the ping options, but that is about it.

Once started, the script will create files named "pinglog-YYYYMMDD.csv" in the current directory, which should load in any spreadsheet that supports csv such as OpenOffice.

To leave it running in the background, I normally use GNU screen.

Download

The script is no longer available.

Comments:

anonymous Image  28/08/2011 19:41 :: anonymous

Did you check out smokeping?

Glen Pitt-Pladdy Image  29/08/2011 07:31 :: Glen Pitt-Pladdy

Yep - smokeping is impressive but not what I needed. My aim was a single script that I could drop on a remote system quickly and with minimum config.

This page actually refers to a very old version - the new version is much cleaner in the way it works.




Are you human? (reduces spam)
Note: Identity details will be stored in a cookie. Posts may not appear immediately