[rrd-users] Problem with custom PHP script - peak traffic
drrake
eckdar at gmail.com
Thu Oct 8 21:52:30 CEST 2009
Hello,
I'm having a problem with getting script to work correctly. I'm trying to
fetch data from a few .rrd files, sum their values and get peak value of
outgoing traffic. Unfortunately the value I get is much lower than it should
be (I'm comparing with a cacti summary graph of the graphs from the same
.rrd files).
What am I doing wrong? Below is the code:
$_SOURCES[] = "a.rrd";
$_SOURCES[] = "b.rrd";
...
$source=0;
foreach ($_SOURCES as $s)
{
unset($out);
unset($_TMPTABLE);
exec("rrdtool fetch $s AVERAGE", $out);
foreach ($out as $line)
{
$l=explode(" ", $line);
$l = preg_replace('/(nan)|(NaN)/', '0.0000000000e+00', $l);
if (preg_match("/^[0-9]/", $l[0]))
{
$t = $l[0];
$_TMPTABLE[$t]=floatval($l[2]);
$_TMPTABLE[$t] = $_TMPTABLE[$t] * 8;
}
}
foreach ($_TMPTABLE as $time => $val)
{
if (preg_match("/^[0-9]/", $val))
{
$_OUTTABLE[$time]= $_OUTTABLE[$time] + $val;
}
}
}
$peak=0;
$peak_time=0
foreach ($_OUTTABLE as $time => $val)
{
if ($val >= $peak)
{
$peak=$val;
$peak_time=$time;
}
}
Thanks in advance for any helpful tips.
--
View this message in context: http://n2.nabble.com/Problem-with-custom-PHP-script-peak-traffic-tp3790452p3790452.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.
More information about the rrd-users
mailing list