Information May Be Out-of-Date
This page about licensing and maintenance is shown for reference purposes only. Information on this page is not maintained and may no longer be valid.
For recent information, please visit our Frequently Asked Questions (FAQs) page.
Using SNMP GET requests in a Custom Script Sensor
This article shows how you can use SNMP GET requests inside a script for a custom sensor.
Using the SNMPGET command you can request any OID of a device and process the results. Note: The IP adress is taken from the associated server of the current sensor.
' This sample IPCheck Custom Sensor Script reads the system uptime and does nothing serious with it... 'initialize sensor's result to status of "error" sensor.resultvalue=0 'For Version 5.2 or earlier use: sensor.resultvalue=0 sensor.status=srError sensor.errortype=etNone 'get the snmp values (as string) 'this OID gives us the system uptime, supported by most devices result=snmpget("public","126.96.36.199.188.8.131.52.0") 'check for errors (always begins with the word "ERROR") if pos("ERROR",result)=1 then sensor.errorstring=result sensor.errortype=etprotocol else mynumber=strtoint(result) \'set result and status sensor.resultvalue=mynumber 'For Version 5.2 or earlier use: sensor.resultvalue=mynumber \'set to error if result is < 10 if freememory < 10 then sensor.status=srError else sensor.status=srok end if end if