[rrd-users] Re: Convert .rrd to .log ?

Greg Cirino gcirino at cirelle.com
Tue Jul 9 00:31:22 MEST 2002


Skeeve wrote:
>Hi... I am really trying to find a solution to this issue I am having.
>I am using the routers.cgi frontend which works great.
>What it doesnt do is have the ability to show total daily usage with 
>historical capability.

>I want to be able to look up what the usage was in.. say January, 
>and being able to show the daily totals.

>Does anyone know how to store historical data?


I've been messing with this as well but ran into a graphing
roadblock.
The numbers are fairly easy to extract but graphing is a
nighmare.

I have a PHP model as I'm not very skilled in perl.
(NOTE: this may or may not be what you are looking for
but it sounded like the headache I have as well. This can be
converted to perl easily - for a skilled perler as the theory
is here. If not well just delete it :))

function read_rrd_file($rrd,$monthnumber,$year ){
$FromMonth = $m;
$FromDay = 1;
$FromYear = $y;
$ToMonth = $m;
$ToDay = 31;
$ToYear = $y;
$config [path_rrdtool]["value"] = "/usr/bin/rrdtool";
$command = "fetch";
$rrdfileloc = "/<your_rrd_file_location>/";
$rrdfilename = $rrd;
$srcfile = $rrdfileloc.$rrdfilename;
$StartDate  = mktime(0,0,0,$FromMonth,$FromDay,$FromYear);
$EndDate     = mktime(23,59,59,$ToMonth,$ToDay,$ToYear);
$consolidation = "MAX"; 
$command_line = $command." ".$srcfile." ";
$command_line .= $consolidation." -s ".$StartDate." -e ".$EndDate;

$fpt=popen($config["path_rrdtool"]["value"] . " $command_line","r");
$return = fread($fpt, 10000000);
pclose($fpt);

return $return;
}

then call the function like

$results =  read_rrd_file($rrdfile,$monthnumber,$year);
$fparr1 = preg_split('/\n/',$results);
$count = count($fparr1);
for($i =0;$i <= $count; $i++){
//other manipulation can go here if you like
echo "$fparr1[$i]<br>";
}

you should get some numbers to work with then do a file write to 
save the monthly stats for historical reasons in the directory of
your choosing.

HTH


Regards
Greg Cirino


--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list