Difference between revisions of "Pass persist"
From Net-SNMP Wiki
m |
m |
||
Line 14: | Line 14: | ||
# you will probably need to add a line to the security section of snmpd.conf, to allow access to the OID subtree. | # you will probably need to add a line to the security section of snmpd.conf, to allow access to the OID subtree. | ||
# I used python to implement my pass_persist script. You must flush stdout after sending each line, otherwise snmpd will timeout after waiting for your response. Or invoke python with -u option (unbuffered stdin/stdout). | # I used python to implement my pass_persist script. You must flush stdout after sending each line, otherwise snmpd will timeout after waiting for your response. Or invoke python with -u option (unbuffered stdin/stdout). | ||
+ | # python stdin.getline() preserves the newline, so you need to strip it. |
Revision as of 09:27, 2 September 2011
The pass_persist option is very useful if you need to implement some specific OID subtree, but it has a few traps and features which are poorly communicated, or not even mentioned in the snmpd.conf man page.
- the shutdown protocol: when the snmpd server wants to shutdown, it tells your script by sending a blank line on stdin.
- snmpd sends a PING at the start of every request (I read the docs to mean that it is sent once, on script startup).
- the list of types you can return is quite limited. It is actually described in the docs for pass, which says that the type must be "one of the text strings: integer, gauge, counter, timeticks, ipaddress, objectid, or string"
- because you cannot return DateAndTime (RFC 2579), for datetime values I've resorted to returning two values (two separate OIDs):
- seconds-since-epoch
- datetime formatted as ISO-8601 string
Other things I've learned:
- your MIB must be valid, otherwise snmpget won't even query the daemon (http://dreness.com/wikimedia/index.php?title=Net_SNMP)
- you will probably need to add a line to the security section of snmpd.conf, to allow access to the OID subtree.
- I used python to implement my pass_persist script. You must flush stdout after sending each line, otherwise snmpd will timeout after waiting for your response. Or invoke python with -u option (unbuffered stdin/stdout).
- python stdin.getline() preserves the newline, so you need to strip it.