Page 1 of 1

Graphing and UOM

Posted: Wed Jul 09, 2014 3:58 pm
by brandon.pal
Nagios Plugin Development Guidelines

'label'=value[UOM];[warn];[crit];[min];[max]
UOM (unit of measurement) is one of:
no unit specified - assume a number (int or float) of things (eg, users, processes, load averages)
s - seconds (also us, ms)
% - percentage
B - bytes (also KB, MB, TB)
c - a continous counter (such as bytes transmitted on an interface)
Base on above I assume value[UOM] should have no space so 10.25c. I have done this but am not getting any graphs. I seem to be getting these new dials in version 2014 and they show the right data but the graphs are all showing -nan.

Why is this?

Re: Graphing and UOM

Posted: Wed Jul 09, 2014 4:01 pm
by tmcdonald
Try dropping the c. It may not work with floats.

Re: Graphing and UOM

Posted: Wed Jul 09, 2014 6:02 pm
by brandon.pal
By doing that it's add a B beside my number and for some reason where I have kb it's changing the numbers completely and showing MB but the math is not correct.

Re: Graphing and UOM

Posted: Thu Jul 10, 2014 7:36 am
by brandon.pal
Let me describe in more detail what is going on:

I have a check in nagios that is probing Disk I/O. My Perf Data looks like this:

Performance Data: rqms=0.00 wrqms=0.20 rs=0.00 ws=0.40 rkBs=0.00KB wkBs=2.40KB avgrqsz=12.00 agqusz=0.00 await=0.25ms svtm=0.25ms percutil=0.01%

My graph data does not match at all.

My graph data is showing the following

rqms=0.00 B CUR
wrqms=1.05 B CUR
rs=0.00 B CUR
ws=470.67 mB CUR
rkBs=0.00 B CUR
wkBs=6.07 B CUR
avgrqsz=22.59 B CUR
agqusz=23.53 mB CUR
await=583.33 B CUR
svtm=500.00 mB CUR

NO graph for percutil.

Now in Nagios XI 2014 they added gauges to the monitoring page. All the gauges are present and show the correct values. Why is my graph completely messing up the numbers.
<?php


# R/W requests merged per second
$opt[1] = "--vertical-label \"Requests Merged \" -l0 --title \" RW requests merged per second \" ";

$def[1] = "DEF:rqms=$rrdfile:$DS[1]:AVERAGE " ;
$def[1] .= "LINE:rqms#00CC00:\"Read \" ";
$def[1] .= "GPRINT:rqms:LAST:\"%3.2lf %sB CUR \" ";
$def[1] .= "GPRINT:rqms:MAX:\"%3.2lf %sB MAX \" ";
$def[1] .= "GPRINT:rqms" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

$def[1] .= "DEF:wrqms=$rrdfile:$DS[2]:AVERAGE " ;
$def[1] .= "LINE:wrqms#FFCC00:\"Write \" ";
$def[1] .= "GPRINT:wrqms:LAST:\"%3.2lf %sB CUR \" ";
$def[1] .= "GPRINT:wrqms:MAX:\"%3.2lf %sB MAX \" ";
$def[1] .= "GPRINT:wrqms" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

#$def[1] .= "CDEF:sum=rrqm,wrqm,+ ";
#$def[1] .= "LINE:sum#00ECE0:\"Sum\" ";
#$def[1] .= "GPRINT:sum" . ':AVERAGE:"%3.2lf %sB AVG \j" ';


# R/W requests issued per second
$opt[2] = "--vertical-label \"Requests Issued \" -l0 --title \" RW requests issued per second \" ";

$def[2] = "DEF:rs=$rrdfile:$DS[3]:AVERAGE " ;
$def[2] .= "LINE:rs#00CC00:\"Read \" ";
$def[2] .= "GPRINT:rs:LAST:\"%3.2lf %sB CUR \" ";
$def[2] .= "GPRINT:rs:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:rs" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

$def[2] .= "DEF:ws=$rrdfile:$DS[4]:AVERAGE " ;
$def[2] .= "LINE:ws#FFCC00:\"Write \" ";
$def[2] .= "GPRINT:ws:LAST:\"%3.2lf %sB CUR \" ";
$def[2] .= "GPRINT:ws:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:ws" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

#$def[2] .= "CDEF:sum2=rs,ws,+ ";
#$def[2] .= "LINE:sum2#00ECE0:\"Sum\" ";
#$def[2] .= "GPRINT:sum2" . ':AVERAGE:"%3.2lf %sB AVG \j" ';


# R/W kb written per second
$opt[3] = "--vertical-label \"KB \" -l0 --title \" RW Written per second \" ";

$def[3] = "DEF:rkBs=$rrdfile:$DS[5]:AVERAGE " ;
$def[3] .= "LINE:rkBs#00CC00:\"Read \" ";
$def[3] .= "GPRINT:rkBs:LAST:\"%3.2lf %sB CUR \" ";
$def[3] .= "GPRINT:rkBs:MAX:\"%3.2lf %sB MAX \" ";
$def[3] .= "GPRINT:rkBs" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

$def[3] .= "DEF:wkBs=$rrdfile:$DS[6]:AVERAGE " ;
$def[3] .= "LINE:wkBs#FFCC00:\"Write \" ";
$def[3] .= "GPRINT:wkBs:LAST:\"%3.2lf %sB CUR \" ";
$def[3] .= "GPRINT:wkBs:MAX:\"%3.2lf %sB MAX \" ";
$def[3] .= "GPRINT:wkBs" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

#$def[3] .= "CDEF:sum3=rkbs,wkbs,+ ";
#$def[3] .= "LINE:sum3#00ECE0:\"Sum\" ";
#$def[3] .= "GPRINT:sum3" . ':AVERAGE:"%3.2lf %sB AVG \j" ';


# Average Size (sectors)
$opt[4] = "--vertical-label \"Sectors \" -l0 --title \" Average request size \" ";

$def[4] = "DEF:avgrqsz=$rrdfile:$DS[7]:AVERAGE " ;
$def[4] .= "LINE:avgrqsz#00CC00:\"Average Size \" ";
$def[4] .= "GPRINT:avgrqsz:LAST:\"%3.2lf %sB CUR \" ";
$def[4] .= "GPRINT:avgrqsz:MAX:\"%3.2lf %sB MAX \" ";
$def[4] .= "GPRINT:avgrqsz" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

# Average Que Length
$opt[5] = "--vertical-label \"Que Length \" -l0 --title \" Average Que Length \" ";

$def[5] = "DEF:agqusz=$rrdfile:$DS[8]:AVERAGE " ;
$def[5] .= "LINE:agqusz#00CC00:\"Que Length \" ";
$def[5] .= "GPRINT:agqusz:LAST:\"%3.2lf %sB CUR \" ";
$def[5] .= "GPRINT:agqusz:MAX:\"%3.2lf %sB MAX \" ";
$def[5] .= "GPRINT:agqusz" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

# Average time/service time
$opt[6] = "--vertical-label \"Milliseconds \" -l0 --title \" Average Time \" ";

$def[6] = "DEF:await=$rrdfile:$DS[9]:AVERAGE " ;
$def[6] .= "LINE:await#00CC00:\"Time \" ";
$def[6] .= "GPRINT:await:LAST:\"%3.2lf %sB CUR \" ";
$def[6] .= "GPRINT:await:MAX:\"%3.2lf %sB MAX \" ";
$def[6] .= "GPRINT:await" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

$def[6] .= "DEF:svtm=$rrdfile:$DS[10]:AVERAGE " ;
$def[6] .= "LINE:svtm#FFCC00:\"Service Time \" ";
$def[6] .= "GPRINT:svtm:LAST:\"%3.2lf %sB CUR \" ";
$def[6] .= "GPRINT:svtm:MAX:\"%3.2lf %sB MAX \" ";
$def[6] .= "GPRINT:svtm" . ':AVERAGE:"%3.2lf %sB AVG \j" ';

# Percentage of CPU time
$opt[5] = "--vertical-label \"% \" -l0 --title \" % of CPU Time \" ";

$def[5] = "DEF:percutil=$rrdfile:$DS[11]:AVERAGE " ;
$def[5] .= "LINE:percutil#00CC00:\"CPU Time \" ";
$def[5] .= "GPRINT:percutil:LAST:\"%3.2lf %sB CUR \" ";
$def[5] .= "GPRINT:percutil:MAX:\"%3.2lf %sB MAX \" ";
$def[5] .= "GPRINT:percutil" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
?>
Any help would be greatly appreciated.

Re: Graphing and UOM

Posted: Thu Jul 10, 2014 10:14 am
by brandon.pal
Please see attached picture of the graph vs the gagues.
cpu_graph_1.jpg
cpu_graph_2.jpg

Re: Graphing and UOM

Posted: Thu Jul 10, 2014 7:47 pm
by Box293
brandon.pal wrote:NO graph for percutil.
I think you've got a simple typo. You've defined $opt[5] and $def[5] whereas they should be $opt[7] and $def[7]
brandon.pal wrote:Why is my graph completely messing up the numbers.
I've played around with templates and I understand your frustrations. Some of the documentation out there doesn't explain what I am about to say so it may not be correct but you'll know once you play around with my suggestion.

Comparing the data:

Code: Select all

Performance Data: ws=0.40
Graph Data: ws=470.67 mB CUR
And here is the corresponding code:

Code: Select all

$def[2] .= "DEF:ws=$rrdfile:$DS[4]:AVERAGE " ;
$def[2] .= "LINE:ws#FFCC00:\"Write \" ";
$def[2] .= "GPRINT:ws:LAST:\"%3.2lf %sB CUR \" ";
$def[2] .= "GPRINT:ws:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:ws" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
When the graph draws the lines and prints the legend, it is taking the values from within the RRD Database. By this time they have already been averaged out (based on the timeframe you are pulling data from). They will never be the same as the original perdata UNLESS the values remain constant (like cpu count of 4 across the whole graph, the max, current and average will always be the same).

To get the LAST value we can draw this from the XML file, as it records everything from the last performance data string returned. Specifically I am talking about the ACT field:

Code: Select all

<ACT>0.40</ACT>
$ACT[4] relates to the ACT field in the XML file for the 4th datasource.

So instead of:

Code: Select all

$def[2] .= "GPRINT:ws:LAST:\"%3.2lf %sB CUR \" ";
Do:

Code: Select all

$def[2] .= "GPRINT:$ACT[4]:\"%3.2lf %sB CUR \" ";
Let me know if this makes sense / helps / works.

Re: Graphing and UOM

Posted: Fri Jul 11, 2014 9:16 am
by brandon.pal
Thank you for noticing my typo.
When I do:
$def[2] .= "GPRINT:$ACT[4]:\"%3.2lf %sB CUR \" ";
My graph just breaks. I can add $ACT[#] to any comment and show the correct value. If I can get he CUR line to work is there way to graph based on that line?

Re: Graphing and UOM

Posted: Fri Jul 11, 2014 8:10 pm
by Box293
I've done a bit of playing and I realise that we can't use the ACT value with the GPRINT, it will only work when used as a comment.

I'm really stretching my knowledge of pnp and rrd so I won't try an explain it in detail (cause it's probably wrong :lol:). My understanding is that GPRINT only works with data that is coming from a database (rrd file) whereas ACT is a static once only value.
brandon.pal wrote: If I can get he CUR line to work is there way to graph based on that line?
Because ACT is a value that occurs only once in the XML file, then we can't use it for graphing.

My suggested solution is to have the ACT value as a comment:

Code: Select all

$def[2] .= "DEF:ws=$rrdfile:$DS[4]:AVERAGE " ;
$def[2] .= "LINE:ws#FFCC00:\"Write \" ";
$def[2] .= "GPRINT:ws:MAX:\"%3.2lf %sB MAX \" ";
$def[2] .= "GPRINT:ws" . ':AVERAGE:"%3.2lf %sB AVG \j" ';
$def[2] .= 'COMMENT:"Last Check Result\: ' . $ACT[4] . '" '