What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

PowerShell XML Script always returns 0

Votes:

0

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.

custom-exe exexml powershell prtg xml

Created on Aug 29, 2013 3:37:51 PM

Last change on Aug 29, 2013 8:11:26 PM by  Greg Campion [Paessler Support]



3 Replies

Accepted Answer

Votes:

0

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.

Created on Aug 29, 2013 8:10:21 PM by  Greg Campion [Paessler Support]



Votes:

0

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.

Created on Aug 30, 2013 7:49:37 AM



Votes:

0

Glad to help!

Created on Aug 30, 2013 9:20:50 AM by  Greg Campion [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.