pysnmp/shell
Les Smithson
lsmithso at NOhare.SPAM.demon.co.uk
Tue Jun 22 12:04:53 EDT 2004
I find the pysnmp API non-intuitive, but maybe that's just me. I've
been thinking about writing a wrapper for it that makes it look more
like the SNMP++ object model, which I'm much more comfortable with.
That said, I did manage to use it to get stats from an ADSL
router. This is a fragment that retrieves and returns the value of a
single OID.
def getVal(s, oid):
encOid = s.encode_oid(s.str2nums(oid))
req = s.encode_request('GETREQUEST', [encOid], [])
answer = s.send_and_receive(req)
i, v = s.decode_response(answer)
val = map(s.decode_value, v)
return val[0]
The pysnmp examples directory has a snmpwalk.py that shows you how to
do a MIB walk, using GETNEXT requests.
More information about the Python-list
mailing list