Plugin Perfdata return not graphing correctly
Posted: Fri Aug 07, 2015 8:09 am
I have a custom made plugin that returns perfdata on multiple lines.
It is a powershell code that runs locally on the server using nrpe.
This is the return as Powershell sees it-
But when I run it through nagios I get the following-
because there's too many letters to fit on the first line it splits the perfdata into two separate bits and doesn't graph properly.
The weird thing is that if I stick in a false perfdata entry at the start which pushes the rest onto a new line then it actually reads it all as one line and graphs perfectly fine-
I read on the Plugin API that "You can return performance data only in subsequent lines (after the first)" so I guess this would be the best option for me- but I cant figure out how to do it, I've tried \n but it doesn't work...
here is the actualy code-
Any thoughts?
It is a powershell code that runs locally on the server using nrpe.
This is the return as Powershell sees it-
Code: Select all
Production Adapter - Primary : 2<BR>Cluster Adapter : 0<BR>|'ProductionAdapterPrimary'=2;1;2 'ClusterAdapter'=0;1;2Code: Select all
Production Adapter - Primary : 1<BR>Cluster Adapter : 0<BR>|'ProductionAdapterP
rimary'=1;1;2 'ClusterAdapter'=0;1;2The weird thing is that if I stick in a false perfdata entry at the start which pushes the rest onto a new line then it actually reads it all as one line and graphs perfectly fine-
Code: Select all
Production Adapter - Primary : 1<BR>Cluster Adapter : 0<BR>|'stupidnrpe123'=0;0;0 'ProductionAdapterPrimary'=1;1;2 'ClusterAdapter'=0;1;2here is the actualy code-
Code: Select all
$num = 0
$perfdata = "|stupidnrpe123=0;0;0 "
#$perfdata = "|"
#Check if any of them should alert and create perfdata
foreach ($adapter in $adaptercount) {
$adapter = [int]$adapter
#replace spaces in names with underscores just incase nrpe is having problems with spaces
$adaptername[$num] = $adaptername[$num] -replace " ",""
$adaptername[$num] = $adaptername[$num] -replace "-",""
#building the perfdata for graphing
$perfdata += "'" + $adaptername[$num] + "'=" + $adapter + ";" + $warn + ";" + $crit + " "
$num++
if ($warn) {
if ($adapter -ge $warn) { $exitcode = 1 }
}
if ($crit) {
if ($adapter -ge $crit) { $exitcode = 2 }
}
if (!$exitcode) { $exitcode = 0 }
}
#Add perfdata to the end of the return
$out += $perfdata
echo $out
exit $exitcode



