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
Powershell via NRPE not returning Perf data correctly
-
btsmnagios
- Posts: 49
- Joined: Tue Mar 07, 2017 9:19 am
Powershell via NRPE not returning Perf data correctly
You do not have the required permissions to view the files attached to this post.
Re: Powershell via NRPE not returning Perf data correctly
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 0Be 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
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
Re: Powershell via NRPE not returning Perf data correctly
I am glad I could help! 
Let us know if you have any further questions.
Let us know if you have any further questions.
Be sure to check out our Knowledgebase for helpful articles and solutions!