oetiker / SmokePing

The Active Monitoring System
http://www.smokeping.org
GNU General Public License v2.0
1.38k stars 184 forks source link

Support parsing IPv6 output in OpenSSHJunOSPing Plugin #398

Closed zimage closed 6 months ago

zimage commented 6 months ago

When pinging by DNS name on Junos, the ping may use IPv4 or IPv6 and the output is different between the two

IPv4 output

PING dns.google (8.8.8.8): 64 data bytes
72 bytes from 8.8.8.8: icmp_seq=0 ttl=122 time=0.549 ms
72 bytes from 8.8.8.8: icmp_seq=1 ttl=122 time=0.503 ms
72 bytes from 8.8.8.8: icmp_seq=2 ttl=122 time=0.853 ms
72 bytes from 8.8.8.8: icmp_seq=3 ttl=122 time=0.839 ms
72 bytes from 8.8.8.8: icmp_seq=4 ttl=122 time=0.850 ms

--- dns.google ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.503/0.719/0.853/0.158 ms

IPv6 output

PING6(112=40+8+64 bytes) 2605:ce80::2 --> 2001:4860:4860::8844
72 bytes from 2001:4860:4860::8844, icmp_seq=0 hlim=122 time=0.631 ms
72 bytes from 2001:4860:4860::8844, icmp_seq=1 hlim=122 time=0.601 ms
72 bytes from 2001:4860:4860::8844, icmp_seq=2 hlim=122 time=0.617 ms
72 bytes from 2001:4860:4860::8844, icmp_seq=3 hlim=122 time=35.073 ms
72 bytes from 2001:4860:4860::8844, icmp_seq=4 hlim=122 time=3.637 ms

--- dns.google ping6 statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/std-dev = 0.601/8.112/35.073/13.531 ms

This patch changes the regular expression used to parse out the "time" value. TBH, the expression could be simplified to /^.* time=(\d+\.\d+) ms$/ and push @times,$1;, but I didn't want to change too much.

oetiker commented 6 months ago

please also update the changes file!

oetiker commented 6 months ago

thanks!