[mrtg] My script not working

Anson Rinesmith arinesmith at bigrivertelephone.com
Tue Jul 19 16:57:25 MEST 2005


Okay, I was not impressed with how the "mrtg-ping-probe", that was included
in my /usr/ports directory, was working. It takes 30 seconds to poll one
IP/URL and return 2 numbers. I knew I could write a faster php/perl script
to do the same thing and return values. When I run the files by hand it runs
fine. Even when included in the .cfg file, when run by hand, it works okay.
But when I included it in my cronjob that runs all of my cfg files, I get
all ZEROs. I'll show you the results of mrtg-ping-probe and my script, as
well as my script and how I am making the call inside the .cfg file.

CALL TO mrtg-ping-probe FROM COMMAND LINE(run time ~10 seconds)
# /usr/local/bin/mrtg-ping-probe www.yahoo.com
103
88

CALL TO my script FROM COMMAND LINE (run time < 250 ms)
# /mrtg/my-ping-probe www.yahoo.com
90
91

LINES INSIDE .CFG FILE
Target[yahoo.ping]: `/usr/local/bin/mrtg-ping-probe www.yahoo.com`
Target[yahoo.ping]: `/mrtg/my-ping-probe www.yahoo.com`


MY SOURCE CODE
#!/usr/local/bin/php -q
<?
$host = $argv[1];

exec("ping -c 5 -i 0 $host",$full_data);
$ping_split = explode('=',$full_data[9]);
$times = explode('/',trim($ping_split[1]));
$min = intval($times[0]); $max = intval($times[2]);
echo "$min\n";
echo "$max\n";
?>

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://lists.ee.ethz.ch/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the mrtg mailing list