Monitoring ping times to a server with Zabbix

By jbayer - Last updated: Tuesday, November 15, 2011 - Save & Share - 2 Comments

We needed to monitor ping times from one server to another, neither being the Zabbix server.  Zabbix doesn’t have a way to do this; the only pings that Zabbix can do are from the Zabbix server to another server.

I wrote the attached script to solve this problem.  Install the script onto each client that you need to do this sort of monitoring, in the /etc/zabbix/externalscripts directory (or wherever you have configured them to be).  Make it executable, and add the following lines to the /etc/zabbix/zabbix_agentd.conf file:

       # For
       UserParameter=pingTimeToServer[*],/bin/bash /etc/zabbix/externalscripts/ $1 $2 $3 $4 $5

Restart the Zabbix client after you put this line in.

You can run the script by hand if you like, the options are: server [option] [count] [maxage] [interval]

server Server to ping, either ip or dns
option blank for a single ping
“loss” to get the percentage of lost pings in a range of pings
“min” to get the minimum time in a range of pings
“avg” to get the average time
“max” to get the max time
count  How many times to ping when doing a range of pings
maxage Max age of tmpfile before doing pings again
interval Interval between pings during a range.  Must be
greater than 0.2 (only root can go less than 0.2)

To use as an item inside Zabbix, create an item (either in a template or a host) with the following options:

Type: Zabbix agent
Key: pingTimeToServer[server [,option [,count [,maxage [,interval]]]]
Type of info: Numeric (float) (except for “loss”)
For loss option:  Numeric (unsigned)
Units: all options except loss:        ms
for loss option:                    %

  pingserver (1.1 KiB, 639 hits)

Posted in Administration, Bash, Zabbix • • Top Of Page

2 Responses to “Monitoring ping times to a server with Zabbix”

Comment from Joost van den Broek
Time January 20, 2012 at 3:49 pm

Thanks, very useful.

Comment from Andre
Time October 17, 2014 at 1:49 am

I noted a small problem in the ping script.
When you ping different target systems, the ping results are always stored in the /tmp/doping file, independent of the target system.

So the values returned are all mixed up.
To solve this, just all .$1 in the lines 51 and 52.

Write a comment