Thứ Tư, 26 tháng 7, 2017

Monitor ping other host using zabbix agent

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:                    %

#cat /etc/zabbix/zabbix_agentd.d/userparameter_ping.conf
UserParameter=custom.ping.reachable[*],/bin/ping -c 1 -W 1 -q -n $1 &> /dev/null && echo 1 || echo 0
#systemctl restart zabbix-agent
Zabbix:
Add new item: Key: custom.ping.reachable[8.8.8.8]
Add new trigger: {Hostname:custom.ping.reachable[8.8.8.8].max(#3)}=0


Share This!


1 nhận xét:

  1. 10 Tut - Sharing Tip And Tut: Monitor Ping Other Host Using Zabbix Agent >>>>> Download Now

    >>>>> Download Full

    10 Tut - Sharing Tip And Tut: Monitor Ping Other Host Using Zabbix Agent >>>>> Download LINK

    >>>>> Download Now

    10 Tut - Sharing Tip And Tut: Monitor Ping Other Host Using Zabbix Agent >>>>> Download Full

    >>>>> Download LINK

    Trả lờiXóa