Ah, I see...
I have extended the script a little bit with channels for status, UPS load, estimated battery runtime and battery voltage (like to share it):
Param(
[string]$hostname,
[string]$community
)
#Get UPS status
$var = cmd /c "C:\Program Files\usr\bin\snmpget.exe" -c $community -v 2c -Oqv $hostname .1.3.6.1.4.1.6574.4.2.1.0
$status = $var.replace(" ","")
$upsstatus = switch -regex ($status)
{
"OBDISCHRG" {"3"; break}
"OLCHRG" {"2"; break}
"OL" {"1"}
}
#Get Battery Charge
$var = cmd /c "C:\Program Files\usr\bin\snmpget.exe" -c $community -v 2c -Oqv $hostname .1.3.6.1.4.1.6574.4.3.1.1.0
$pos = $var.IndexOf(".")
$leftPart = $var.Substring(0, $pos)
#Get battery runtime
$var = cmd /c "C:\Program Files\usr\bin\snmpget.exe" -c $community -v 2c -Oqv $hostname .1.3.6.1.4.1.6574.4.3.6.1.0
$time = $var/3600
#Get current load
$var = cmd /c "C:\Program Files\usr\bin\snmpget.exe" -c $community -v 2c -Oqv $hostname .1.3.6.1.4.1.6574.4.2.12.1.0
$pos = $var.IndexOf(".")
$load = $var.Substring(0, $pos)
#Get battery voltage
$var = cmd /c "C:\Program Files\usr\bin\snmpget.exe" -c $community -v 2c -Oqv $hostname .1.3.6.1.4.1.6574.4.3.2.1.0
$voltage = $var
#Create Sensor
Write-Host "<prtg>"
Write-Host "<result>"
Write-Host "<channel>UPS Status</channel>"
Write-Host "<value>$upsstatus</value>"
Write-Host "<valuelookup>prtg.standardlookups.Synology.UPSstatus</valuelookup>"
Write-Host "</result>"
Write-Host "<result>"
Write-Host "<channel>Battery Charge Level</channel>"
Write-Host "<value>$leftPart</value>"
Write-Host "<unit>Percent</unit>"
Write-Host "<LimitMinError>30</LimitMinError>"
Write-Host "<LimitMinWarning>40</LimitMinWarning>"
Write-Host "<LimitMode>1</LimitMode>"
Write-Host "</result>"
Write-Host "<result>"
Write-Host "<channel>UPS load</channel>"
Write-Host "<value>$load</value>"
Write-Host "<unit>Percent</unit>"
Write-Host "<LimitMaxError>95</LimitMaxError>"
Write-Host "<LimitMaxWarning>90</LimitMaxWarning>"
Write-Host "<LimitMode>1</LimitMode>"
Write-Host "</result>"
Write-Host "<result>"
Write-Host "<channel>Battery Est. Runtime</channel>"
Write-Host "<value>$time</value>"
Write-Host "<unit>s</unit>"
Write-Host "<float>1</float>"
Write-Host "<LimitMinError>0.1</LimitMinError>"
Write-Host "<LimitMinWarning>0.2</LimitMinWarning>"
Write-Host "<LimitMode>1</LimitMode>"
Write-Host "</result>"
Write-Host "<result>"
Write-Host "<channel>Battery Voltage</channel>"
Write-Host "<value>$voltage</value>"
Write-Host "<unit>V</unit>"
Write-Host "<float>1</float>"
Write-Host "<LimitMode>1</LimitMode>"
Write-Host "</result>"
Write-Host "</prtg>"
You need this lookup to show the status circle:
<?xml version="1.0" encoding="UTF-8"?>
<ValueLookup id="prtg.standardlookups.Synology.UPSstatus" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd">
<Lookups>
<SingleInt state="Ok" value="1">AC Power</SingleInt>
<SingleInt state="Warning" value="2">AC Power / Battery charging</SingleInt>
<SingleInt state="Error" value="3">Battery Power</SingleInt>
</Lookups>
</ValueLookup>
Kind regards
Ingo
Edit: Added <valuelookup>prtg.standardlookups.Synology.UPSstatus</valuelookup> to the output of the first channel "UPS Status".
NEW:: As of 05/08/2015 PRTG is able to natively recognize this datatype. More info below
Add comment