Powershell via NRPE not returning Perf data correctly

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
btsmnagios
Posts: 49
Joined: Tue Mar 07, 2017 9:19 am

Powershell via NRPE not returning Perf data correctly

Post by btsmnagios »

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
ShareSize Check.JPG

----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
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Powershell via NRPE not returning Perf data correctly

Post by lmiltchev »

I believe the problem is caused by the commas in the numbers. You can try getting rid of them, maybe using something like this:

Code: Select all

$ShareName = $Result.ShareName
$ShareSize = $Result.ShareSize
$FreeSpace = $Result.FreeSpace
$TotalSize = $Result.TotalSize


$Message = "OK - $ShareName`, ShareSize:- $ShareSize`GB, FreeSpace:- $FreeSpace`GB, TotalSize:- $TotalSize`GB"
$output =  "'ShareSize'=$ShareSize`GB 'FreeSpace'=$FreeSpace`GB 'TotalSize'=$TotalSize`GB;"
$perfdata = '{0:f2}' -f $output

write-host $perfdata
write-host $Message"|"$perfdata
Exit 0
Be sure to check out our Knowledgebase for helpful articles and solutions!
btsmnagios
Posts: 49
Joined: Tue Mar 07, 2017 9:19 am

Re: Powershell via NRPE not returning Perf data correctly

Post by btsmnagios »

Thank you so much for your help you were correct, as soon as I removed the comma it worked, only need to sort out NRPE timing out after 60 seconds now, thanks again
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Powershell via NRPE not returning Perf data correctly

Post by lmiltchev »

I am glad I could help! :)

Let us know if you have any further questions.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked