Better? script

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

Moderators: Moderators, Developers

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

Better? script

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

The current script for pinging hosts only does one ping. Here is an updated 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/ file.

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

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

print $2;

Post Reply