[rrd-users] Please check my RRA's configuration
Michał Obrembski
systerneox at wp.pl
Wed May 29 09:55:26 CEST 2013
Hi all!
Recently, i've started learning RRDTool.
What i'm trying to do, is to create 5 grahs from RRD's database of random numbers.
Numbers are inserted to RRD with default, 5 minutes interval. Here's PHP code which generates RRDs and graphs and inserts data into database:
function create_graph($output, $start, $end, $title, $rrd) {
$options = array(
"--start", $start,
"--end", $end,
"--title","\"".$title."\"",
"DEF:success=Test.rrd:success:LAST",
"DEF:failure=Test.rrd:failure:LAST",
"CDEF:tsuccess=success,300,*",
"CDEF:tfailure=failure,300,*",
"LINE2:tsuccess#FF0000",
"LINE2:tfailure#00FF00",
"GPRINT:tfailure:MIN:FailureMin%7.2lf%s",
"GPRINT:tfailure:MAX:FailureMax%7.2lf%s",
"GPRINT:tsuccess:MIN:SuccessMin%7.2lf%s",
"GPRINT:tsuccess:MAX:SuccessMax%7.2lf%s",
);
$rrd->rrdgraph($output,$options);
}
function create_graph2($output, $start, $end, $title, $rrd) {
$options = array(
"--start", $start,
"--end", $end,
"--title","\"".$title."\"",
"DEF:success=Test.rrd:success:AVERAGE",
"DEF:failure=Test.rrd:failure:AVERAGE",
"CDEF:tsuccess=success,300,*",
"CDEF:tfailure=failure,300,*",
"LINE2:tsuccess#FF0000",
"LINE2:tfailure#00FF00",
"GPRINT:tfailure:MIN:FailureMin%7.2lf%s",
"GPRINT:tfailure:MAX:FailureMax%7.2lf%s",
"GPRINT:tsuccess:MIN:SuccessMin%7.2lf%s",
"GPRINT:tsuccess:MAX:SuccessMax%7.2lf%s",
);
$rrd->rrdgraph($output,$options);
}
$rrd = new rrd_exec_access();
$arr = array(
"--step" => "300",
//"-b" => "now-6m",
"DS:success:ABSOLUTE:600:0:U",
"DS:failure:ABSOLUTE:600:0:U",
"RRA:LAST:0.5:1:3258720",
"RRA:AVERAGE:0.5:288:31",
"RRA:MIN:0.5:288:31",
"RRA:MAX:0.5:288:31",
"RRA:AVERAGE:0.5:8928:12",
"RRA:MIN:0.5:8928:12",
"RRA:MAX:0.5:8928:12",
"RRA:AVERAGE:0.5:107136:1",
);
$rrd->rrdcreate("Test.rrd",$arr);
$now = time();
$end = $now+(3600*24*14);
for ($t=$now; $t<=$end; $t+=300) {
$success = rand(0, 100);
$failure = rand(0, 100);
//$precent = ($t/($end/100))*100;
$rrd->rrdupdate("Test.rrd","$t:$success:$failure");
//echo $precent."%\n";
}
create_graph("login-hour.gif", "now", "+1h", "Hourly login attempts",$rrd);
create_graph2("login-day.gif", "now", "+24h", "Daily login attempts",$rrd);
create_graph2("login-week.gif", "now", "+1w", "Weekly login attempts",$rrd);
create_graph2("login-month.gif", "now", "+1m", "Monthly login attempts",$rrd);
create_graph2("login-year.gif", "now", "+1y", "Yearly login attempts",$rrd);
I want to create hourly graph, which will shows actual data whose were inserted, a daily graph with the average for every hour, Weekly for average for every day in a week etc.
SO, for daily graphs it should be
"RRA:AVERAGE:0.5:12:24", - 12 probes in hour, 24 hours
for monthly:
"RRA:AVERAGE:0.5:288:31", - 288 probes in month, 31 months
Graphs looks ok, the problem is with daily graph. It shows only difference between days (the average from day), not between hours in a day.
I think i misunderstood something, could you help me with it?
Michal Obrembski
More information about the rrd-users
mailing list