Monitoring ping times to a server with Zabbix

By jbayer - Last updated: Tuesday, November 15, 2011 - Save & Share - One Comment

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 pingserver.sh
       UserParameter=pingTimeToServer[*],/bin/bash /etc/zabbix/externalscripts/pingserver.sh $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:

       pingserver.sh 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, 622 hits)

Posted in Administration, Bash, Zabbix • • Top Of Page
3,805 views

One Response 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.

Write a comment

asd