0

Dears,

I have a weird issue with my pnp4nagios,

In fact i have a nagios server and a lot of graphs using pnp4nagios, however, i only have a problem with a single graph.

The problem is that it only draw the graph for the last 3 days.

The below code is my php code for the graph.

<?php

  $ds_name[1] = "Total";

 $opt[1] = "-l 0 --vertical-label \"Numbers\"  --title \"$hostname / $servicedesc\" ";
$opt[1] .= '--slope-mode ';
  # QUEUE
  $def[1] = "DEF:queue=$RRDFILE[1]:$DS[1]:LAST " ;

  # Total
  $def[1] .= "DEF:total=$RRDFILE[1]:$DS[2]:LAST " ;

  # Available
  $def[1] .= "DEF:available=$RRDFILE[1]:$DS[3]:LAST " ;

  # Busy
  $def[1] .= "DEF:busy=$RRDFILE[1]:$DS[4]:LAST " ;

  # OnCall
  $def[1] .= "DEF:oncall=$RRDFILE[1]:$DS[5]:LAST " ;



  #Available
  $def[1] .= rrd::cdef("available_temp", "available,busy,+,oncall,+");
  $def[1] .= rrd::gradient("available_temp", "08870a", "04cc07", "Available", 20);

  $def[1] .= "GPRINT:available:LAST:\"%.0lf  LAST \" ";
  $def[1] .= "GPRINT:available:MAX:\"%.0lf  MAX \" ";
  $def[1] .= "GPRINT:available:AVERAGE:\"%.0lf  AVERAGE \\n\" ";

 #Busy
  $def[1] .= rrd::cdef("busy_temp", "busy,oncall,+");
  $def[1] .= rrd::gradient("busy_temp", "ffbf00", "ff8000", "Busy     ", 20);

  $def[1] .= "GPRINT:busy:LAST:\"%.0lf  LAST \" ";
  $def[1] .= "GPRINT:busy:MAX:\"%.0lf  MAX \" ";
  $def[1] .= "GPRINT:busy:AVERAGE:\"%.0lf  AVERAGE \\n\" ";

  #OnCall
  $def[1] .= rrd::gradient("oncall", "4000ff", "0040ff", "On Call  ", 20);

  $def[1] .= "GPRINT:oncall:LAST:\"%.0lf  LAST \" ";
  $def[1] .= "GPRINT:oncall:MAX:\"%.0lf  MAX \" ";
  $def[1] .= "GPRINT:oncall:AVERAGE:\"%.0lf  AVERAGE \\n\" ";


  $def[1] .= rrd::cdef("queue_temp", "queue,-1,*");
  $def[1] .= rrd::gradient("queue_temp", "ff00ff", "bf00ff", "Queue    ", 20);
  $def[1] .= "GPRINT:queue:LAST:\"%.0lf  LAST \" ";
  $def[1] .= "GPRINT:queue:MAX:\"%.0lf  MAX \" ";
  $def[1] .= "GPRINT:queue:AVERAGE:\"%.0lf  AVERAGE \\n\" ";

#Total ( The Red Line)
  $def[1] .= rrd::line2("total", "#ff0000", "Total    ");
  $def[1] .= "GPRINT:total:LAST:\"%.0lf  LAST \" ";
  $def[1] .= "GPRINT:total:MAX:\"%.0lf  MAX \" ";
  $def[1] .= "GPRINT:total:AVERAGE:\"%.0lf  AVERAGE \\n\" ";

?

>

2 Answers2

0

I don't believe this is something that's decided by the template. Have a look at timeranges in the doc, it seems that this is set in the URL you access pnp4nagios with.

Example (notice start=):

pnp4nagios/graph?host=<hostname>&srv=<servicedesc>&start=-1week

pzkpfw
  • 318
  • 2
  • 12
0

In fact i solved the issue by changing the " Last " to "average " and don't asking why the average works and the last doesn't because that was really weird and unexpected.