Atom Feed
Comments Atom Feed

Similar Articles

2011-06-15 09:34
Universal Log Analyser and snmpd extension scripts
2011-12-22 09:30
Peak Network Bandwidth for Cacti
2011-08-24 19:10
TEMPer under Linux (perl) with Cacti
2014-02-16 13:12
PICing up 433MHz Signals for OSS Home Automation - Part 5
2011-06-25 12:33
Dovecot stats on Cacti (via SNMP)

Recent Articles

2019-07-28 16:35
git http with Nginx via Flask wsgi application (git4nginx)
2018-05-15 16:48
Raspberry Pi Camera, IR Lights and more
2017-04-23 14:21
Raspberry Pi SD Card Test
2017-04-07 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
2017-03-28 13:07
Kubernetes to learn Part 4

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.


The script is no longer available.