Powershell via NRPE not returning Perf data correctly
Posted: Tue Apr 16, 2019 3:23 am
I have written a script that connect to my shares and returns the size info of the shares, this works correctly and returns the data to Nagios with the correct statement and the size info, but when I start adding in the perf data as per the documentation using the pipe character as the separator and formatting in the correct way the data in the variables are being returned as 0, I have attached a picture showing the check and the first line returned is what should be after the pipe | with the data in and the second line is what should actually be returned but the data is becoming 0 after the pipe, below is the code I am using, thanks for any help in advance
----Code----
$ShareName = $Result.ShareName
$ShareSize = $Result.ShareSize
$FreeSpace = $Result.FreeSpace
$TotalSize = $Result.TotalSize
$Message = "OK - $ShareName`, ShareSize:- $ShareSize`GB, FreeSpace:- $FreeSpace`GB, TotalSize:- $TotalSize`GB"
$perfdata = "'ShareSize'=$ShareSize`GB 'FreeSpace'=$FreeSpace`GB 'TotalSize'=$TotalSize`GB;"
write-host $perfdata
write-host $Message"|"$perfdata
Exit 0
----Code----
$ShareName = $Result.ShareName
$ShareSize = $Result.ShareSize
$FreeSpace = $Result.FreeSpace
$TotalSize = $Result.TotalSize
$Message = "OK - $ShareName`, ShareSize:- $ShareSize`GB, FreeSpace:- $FreeSpace`GB, TotalSize:- $TotalSize`GB"
$perfdata = "'ShareSize'=$ShareSize`GB 'FreeSpace'=$FreeSpace`GB 'TotalSize'=$TotalSize`GB;"
write-host $perfdata
write-host $Message"|"$perfdata
Exit 0