utorok 31. decembra 2019

Changes on my cacti 1.2.2 on my RPi

I changed ping.pl (sitting in /usr/share/cacti/site/scripts) to:

$host     = $ARGV[0];
$count    = 10;
$host =~ s/tcp:/$1/gis;
$host =~ s/:[0-9]{1,5}/$1/gis;
my @data, @timings, @loss;
$pid = open(PROCESS, "/bin/ping -c $count -q $host |");
while (<PROCESS>) {
    push (@data, <PROCESS>);
@loss = split("received, ", @data[2]);
@loss = split("%", @loss[1]);
if (@loss[0] eq "100.0") {
    print "min:U avg:U max:U dev:U loss:100.00";
} else {
    @timings = split(" = ", @data[3]);
    @timings = split(" ms", @timings[1]);
    @timings = split("/", @timings[0]);
#    print @data;
    print "@timings[1]";

Reason: original ping.pl was sending one packet, which casued, that latency measure was innacurate.
If provided script takes too long to run for you, send less packets ($count). Even three packets are better than one.
This script is a modification of a script found on forums.cacti.net.

You can see the difference.

Žiadne komentáre:

Zverejnenie komentára