Radu Radu Radu Radu - 2 years ago 137
PHP Question

rrdtool graphing only 10 hours

I have a strage issue graphing rrdtool, but not always.

I will try to explain.
I have 2 databases (data1.rrd and data2.rrd) and I graph 1h, 12h, 24h, 1w, 1m and 1y, but for some reason, sometimes the graphs only show 10h of time lapse.

I initializated the database as follow:

${rrdtool} create ${rrd_dir}/temperatures.rrd \
--step ${step} \
DS:temp_cpd:GAUGE:120:0:U \
DS:temp_cpd_pecera:GAUGE:120:0:U \
DS:temp_cmts_catv:GAUGE:120:0:U \


$rrdtool update ${rrd_file} --template temp_cpd:temp_cpd_pecera:temp_cmts_catv N:${temp_cpd}:${temp_cpd_pecera}:${temp_cmts_catv}


$rrdtool graph ${graph_dir}/temperatures-${start}.png \
--height=120 \
--width=500 \
--rigid \
--start -${start} \
--end now \
--watermark "`date +'%Y-%m-%d %H:%M - Radu Radu'`" \
--imgformat=PNG \
--title="${graph_desc}" \
-w 600 -h 200 \
--alt-autoscale-max \
--lower-limit 18 \
--vertical-label "Temperatura (ºC)" \
DEF:temp_cpd=${rrd_file}:temp_cpd:AVERAGE \
DEF:temp_cpd_pecera=${rrd_file}:temp_cpd_pecera:AVERAGE \
DEF:temp_cmts_catv=${rrd_file}:temp_cmts_catv:AVERAGE \
CDEF:ok_cpd=temp_cpd,100,/ \
CDEF:ok_cpd_pecera=temp_cpd_pecera,100,/ \
CDEF:ok_cmts_catv=temp_cmts_catv,100,/ \
LINE1:ok_cpd#ff0000:'CPD\t\t\t' \
GPRINT:ok_cpd:LAST:'Actual\:%6.2lf ºC' \
GPRINT:ok_cpd:AVERAGE:'Promedio\:%6.2lf ºC' \
GPRINT:ok_cpd:MAX:'Máximo\:%6.2lf ºC\n' \
LINE1:ok_cpd_pecera#00ff00:'CPD Pecera\t\t' \
GPRINT:ok_cpd_pecera:LAST:'Actual\:%6.2lf ºC' \
GPRINT:ok_cpd_pecera:AVERAGE:'Promedio\:%6.2lf ºC' \
GPRINT:ok_cpd_pecera:MAX:'Máximo\:%6.2lf ºC\n' \
LINE1:ok_cmts_catv#0000ff:'CMTS CATV\t\t' \
GPRINT:ok_cmts_catv:LAST:'Actual\:%6.2lf ºC' \
GPRINT:ok_cmts_catv:AVERAGE:'Promedio\:%6.2lf ºC' \
GPRINT:ok_cmts_catv:MAX:'Máximo\:%6.2lf ºC\n' \

The poller run every minute and do the command for the temperature gathering.

Another question, can I redirect the output of the graph poller to stdout and then print In php loop the content? because now I'm saving the *.png in /graficas/FREQUENCY/HOST_NAME-GRAPH_NAME-INDEX.png and then I acces it as follow:

if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {

echo "
<div class= 'graphSize' style='float:left'>
<a href='?page=GraphDetail&graph_id=".$row['graph_id']."&graph_desc=".$row['graph_desc']."'><img style='width:100%' src='/graficas/".$freq."/".$row['graph_name']."' onload='refreshIt(this)'></img></a>

else {
echo "<p>No hay ninguna gráfica para mostrar</p>"; }

But I don't like this method because if anyone "know" my path can access the graphs.

PD: I'm a bit newbie with rrdtool I just crafted the graph following the documentation in oetiker's web.

Answer Source

The solution was initializing the database adding this parameters:

    RRA:AVERAGE:0.5:1:600 \
    RRA:AVERAGE:0.5:6:700 \
    RRA:AVERAGE:0.5:24:775 \
    RRA:AVERAGE:0.5:288:797 \
    RRA:MAX:0.5:1:600 \
    RRA:MAX:0.5:6:700 \
    RRA:MAX:0.5:24:775 \
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download