Hello,
I have built a PowerShell script to monitor my SAN IOPS, but for some reason I cannot get PRTG to show the result value. The script basically runs a command to dump the IOPS of the SAN to CSV, and I then extract the information I need and write it out to XML.
Here is the script:
$outputFile = "C:\PRTG\MDoutput.csv" Set-Location "C:\PRTG" .\SMcli.exe hostname -S -quick -c "show allVirtualDisks performanceStats;" > $outputFile #remove first line in file $csv = Get-Content $outputFile $csv = $csv[1..($csv.count - 1)] $csv > $outputFile #remove all blank lines Select-String -Pattern "\w" $outputFile | ForEach-Object {$_.line} | Set-Content "C:\PRTG\MDoutput2.csv" del $outputFile rename-item "C:\PRTG\MDoutput2.csv" $outputFile $string1 = Import-CSV $outputFile | ? {$_."Storage Arrays " -eq "STORAGE ARRAY TOTALS"} | ForEach-Object { foreach ($property in $_.PSObject.Properties) { if ($property.Name -match "Current IO/second") { $iops = $property.Value } } } Write-Host "<prtg>" Write-Host "<result>" Write-Host "<channel>Current Storage IOPS</channel>" Write-Host "<value>$iops</value>" Write-Host "</result>" Write-Host "</prtg>" I can run the script from the PRTG Server manually with no problems, and it shows the following output (which I was expecting): <prtg> <result> <channel>Current Storage IOPS</channel> <value>164.0</value> </result> </prtg>
I have also enabled the "Write EXE result to disk" to make sure that the script is running OK within PRTG; again it shows the following information within the log file:
<prtg> <result> <channel>Current Storage IOPS</channel> <value>164.0</value> </result> </prtg>
No matter what I do I can't get PRTG to show the correct value, and it always shows 0. See screenshot: https://dl.dropboxusercontent.com/u/3265030/Capture.PNG.
Any help on this would be greatly appreciated.
Article Comments
Thanks for the reply - your suggestion of adding <float> to my script has indeed worked and I am now seeing numbers being returned! Thanks for your time, and thanks for a quick answer to my problem.
Aug, 2013 - Permalink
It should work if you tell prtg that the value will be a floating point value.
<Float> — Define if the value is a float. Default is 0 (no). If set to 1 (yes), use a dot as decimal seperator in values. Note: Define decimal places with the <DecimalMode> element. 0 (= no, integer) 1 (= yes, float)
<DecimalMode> — Init value for the Decimal Places option. If 0 is used in the <Float> element (i.e. use integer), the default is Auto; otherwise (i.e. for float) default is All. Note: In the sensor's Channels tab, you can change this initial setting later. Auto All
<float>1</float> <value>38.4487</value>
You can check the PRTG API->Custom Sensors tab for more information in under Setup in the web console.
Aug, 2013 - Permalink