0

I would like to graph average ping results from Windows-based Zabbix agents to our cloud-based call center server's remote addresses. I've figured out how to return a result of 1 (successful ping) or 0 (unsuccesful ping), but this is useless in my scenario.

I know this is not inherent to Zabbix in any way. The only way I've found that was even close, was to setup a UserParameter in the zabbix_agentd.conf file that pings the remote IP address, and GREPs the required info. Unfortunately, GREP will only return the value of the entire line containing the string I'm looking for.

For example (pinging from the Zabbix agent):

ping 192.168.120.1 | grep "Average ="

returns:

Minimum = 46ms, Maximum = 51ms, Average = 49ms

All I really want returned is 49. That way I can graph the results in a useful manner.

user2548086
  • 1
  • 1
  • 1

1 Answers1

1

This is not really a zabbix question. But anyway. I don't have windows handy, so I can't give you the exact cmd.exe code. Generally what you need is to split the string by tokens (space) and remove the "ms" from the number. Using cmd.exe you can do it as described here for the first part. for the second, there is a plenty of examples here on how to manipulate the strings.

Given you use grep, I can assume you have installed cygwin or something. Then you may have better luck with awk and sed for this. Example

$ ping -c 1 8.8.8.8 | grep "packet loss"
1 packets transmitted, 1 received, 0% packet loss, time 25ms    
$ ping -c 1 8.8.8.8 | awk '/packet loss/ { gsub("%","",$6);print $6}'
0

And the best advice I can give is to use a more advanced language for this kind of operations. Powershell or VB on windows.

Michael Tabolsky
  • 3,429
  • 2
  • 18
  • 11