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.
Add comment