Better? ping.pl script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Moderators, Developers

Post Reply
Author
Message
reshman
Posts: 1
Joined: Thu Mar 22, 2007 12:37 pm

Better? ping.pl script

#1 Post by reshman » Thu Mar 22, 2007 12:42 pm

The current ping.pl script for pinging hosts only does one ping. Here is an updated ping.pl script that takes the average ping times over 7 pings. This was tested on Cacti 0.8.6j on FreeBSD 6.0, so milage may vary with other OS's. this is in the cacti/scripts/ping.pl file.

Forgive me if there is a better way to do this in Perl -- I pretty much hacked this as best i could.

#!/usr/bin/perl
open(PROCESS, "/sbin/ping -c 7 $ARGV[0] | grep round-trip |");
$ping = <PROCESS>;
close(PROCESS);
$ping =~ m/(.* = .*\/)(.*)(\/.*\/.*)/;

print $2;

Post Reply