Using an SNMP Custom String sensor, how can I specify "No such instance" (SNMP error # 223) as Normal/Ok?
I have a device with dry contacts that can be monitored with SNMP. When the contacts are "closed" I get an SNMP response as "High Temperature" which is pretty easy to alert off of with configuring the settings to "Response Must Not Include" to "High Temperature". The problem is that when the contacts are "open", the SNMP response is "No such instance". So is there a way to configure PRTG to show green and "Ok" when the device responds with "No such instance"?
Or is there a way to use an SNMP Custom String Lookup sensor to show "No such instance" as green and "Ok"?
Thanks for your help.
Article Comments
Hi Willi,
PRTG will always evaluate the "No such name" as an error condition and it will not be possible to differentiate between the status.
It will still be possible to perform the check with a custom sensor and process the results. This could be possible by creating an if-condition to return the value if available and to return 0 for everything else.
You can have a look at this article which describes this process with NetSNMP and PowerShell.
This is a simple example based on the linked example above:
cls
$var = cmd /c "snmpget.exe" -c "public" -v 2c -Oqv "%%HOSTNAME%%" .1.3.6.1.2.1.31.1.1.1.18.15 2>&1
if ($LASTEXITCODE -ne 0){
$upsstatus = 0
}else{
$status = $var.replace(" ","")
$upsstatus = switch -regex ($status){
"Other Thing" {"2"; break}
"High Temperature" {"1"; break}
default {"0"}
}
}
Write-Host "<prtg>"
Write-Host "<result>"
Write-Host "<value>$($upsstatus)</value>"
Write-Host "</result>"
Write-Host "</prtg>"
Essentially the "relevant" part of the script is 2>&1 that "catches" the error and then the ($LASTEXITCODE -ne 0) captures any issues with the execution and returns 0 when there an errors. This is intended to be used with lookups:
Best regards, Felix
Oct, 2016 - Permalink
Hi Willi,
PRTG will always evaluate the "No such name" as an error condition and it will not be possible to differentiate between the status.
It will still be possible to perform the check with a custom sensor and process the results. This could be possible by creating an if-condition to return the value if available and to return 0 for everything else.
You can have a look at this article which describes this process with NetSNMP and PowerShell.
This is a simple example based on the linked example above:
Essentially the "relevant" part of the script is 2>&1 that "catches" the error and then the ($LASTEXITCODE -ne 0) captures any issues with the execution and returns 0 when there an errors. This is intended to be used with lookups:
Best regards, Felix
Oct, 2016 - Permalink