snmp python.

anthony baxter (anthony.baxter@aaii.oz.au)
Sat, 04 Feb 1995 04:09:21 +1100

after far too long a break, I'm back bashing SNMP python module into shape.

I want to get some input from interested folks on the API - rather
than cluttering the list up with this discussion, could anyone who's
interested reply to me.

Similarly, if you want to help test this, please let me know - I'd like
to test this (and the library that comes with it) on as many platforms
as possible, before a general release.

thanks!

Anthony

---------------------------------------------------------------------------
import snmp

snmp.open("hostname"[,"community"[,version]])
returns an instance of an SnmpSession object. community defaults to
"public", and version to 1. Note that version != 1 will raise an
exception at the moment.

snmp_session.get("system.sysDescr.0")
returns a tuple of (oid, value, type) (type is redundant now, can get it
from oid. oid is a mibnode object (see below)

snmp_session.get(["system.sysDescr.0","system.sysUptime.0",... ])
will return a list of tuples of (oid, value, type), in the same
order they were passed (hopefully :) Note that passing a list of
one string is _not_ the same as passing one string that is not
in a list.

snmp_session.getnext("system.sysDescr.0") (aka s.thepowerfulgetnext() )
returns a tuple of (oid, value, type). Can also take a list (see get).

snmp_session.set("system.sysDescr.0","some box")
WARNING: This has _not_ been rigorously tested. I'd love feedback on
whether it works properly.

snmp_session.mibnode("system.sysDescr")
Returns a mibnode object (see below) (to get the root of the mib, use
mibnode('.iso') or mibnode('.'))

`mibnode`
returns full name of the node, eg '.iso.....sysDescr.0'

mibnode.get()
mibnode.getnext()
mibnode.set()
work as you'd expect - like the above...

mibnode.suboid
returns a new mibnode for the new node. eg

a=s.mibnode['system']
b=a.sysDescr

mibnode[suboid]
alternative syntax for mibnode.suboid. Use when 'suboid' is a number,
or contains an illegal character (eg '-'). Suboid can be a number or
a string.

mibnode.enums()
returns a dictionary of enums for the node (or None, if there are no
enums defined for this node. You can use value from a 'get'
operation to lookup on this dict.

mibnode.type()
returns type of mibnode.

mibnode.attrs()
returns attributes of mibnode.

mibnode.nodes()
returns list of child nodes of this node in the Mib tree.
As an added bonus, you can get the same info from
for i in mibnode:

snmp.trap()
currently unimplemented.

snmp.checkoid("some.object.id")
returns 1 if the string is a valid objid, 0 otherwise.