powershell - Nagios PNP4Nagios Averaging Integer Value? -


i have powershell script in nagios returns integer using built-in windows netstat command. command follows:

$conns = nestat -na | select-string -pattern "established" $numberofconnections = $conns.count $numberofconnections 

the output like:

123 

works expected. when graph nagios , run check every 3 minutes, result graphed in pnp4nagios 120.657 or 125.124 (it's averaging value float instead of graphing integer).

does know how can force nagios , pnp4nagios rrdtool graphing specific service check not average or round result? in fact, because it's integer, don't want decimal points @ all. ideas?

first off, should check perfdata itsself returned check - should 'key'=value following valid perfdata specifications.

then idea how pnp4nagios templates work - depending on version (0.6 actively developed), e.g. here: [1]

the templates looked check command name default (so if did not create 1 custom check, there's default.php template used).

depending how installed pnp4nagios, templates directory can found below $prefix/share/templates.dist - place yours $prefix/share/templates prevent them being lost during upgrades. copy $prefix/share/templates.dist/default.php $prefix/share/templates/<yourcheckcommandname>.php , start edit (make sure webserver's user may open it).

you'll see creating call rrdtool, appended strings in php code mostly. regarding problem:

  • you not want have avg, current value in legend
  • floating point formatting isn't desired

looking @

$def[$key]  = rrd::def     ("var1", $val['rrdfile'], $val['ds'], "average"); $def[$key] .= rrd::gradient("var1", "3152a5", "bdc6de", rrd::cut($val['name'],16), 20); $def[$key] .= rrd::line1   ("var1", $_line ); $def[$key] .= rrd::gprint  ("var1", array("last","max","average"), "%3.4lf%s".$val['unit']); 

in first line you'll define var1 "average". play around , set "last" if consolidation fits better when drawing graph.

the last line gprintf follows printf syntax, lf double precision 4 , 3 numbers @ front (3.4) [2] changing %lf %d (integer) resolve issue legend.

you may change follows e.g.

$def[$key]  = rrd::def     ("var1", $val['rrdfile'], $val['ds'], "last"); $def[$key] .= rrd::gradient("var1", "3152a5", "bdc6de", rrd::cut($val['name'],16), 20); $def[$key] .= rrd::line1   ("var1", $_line ); $def[$key] .= rrd::gprint  ("var1", array("last","max","average"), "%d %s".$val['unit']); 

there's further possibilities on templates - scaling y-axis, etc - that's rrdtool syntax then.

for printing latest value how nagios/icinga core sent perfdata pnp4nagios can use trick - pnp stores additional data not fit rrd storage in own *.xml files. xml files updated every normal rrd update run process_perfdata.pl then. 1 of them "act" (check [1]) can accessed on first datasource $act[1] in template code, , passed comment string rrdtool call.

$def[$key] .= "comment:\"current $act[$key]\\n\" ";" 

[1] http://docs.pnp4nagios.org/pnp-0.6/tpl

[2] http://www.cdf.toronto.edu/~ajr/209/notes/printf.html


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -