python-snmpclient

Wrapper around pysnmp4 for easier snmp querying


License
Other
Install
pip install python-snmpclient==0.5

Documentation

snmpclient

A utility library for easier use of pysnmp4

Utility functions

snmpclient.add_mib_path(path)

This function adds a directory to the internal MIB search path.

snmpclient.load_mibs(*modules)

This function loads one or more pysnmp-format MIBs. Beware that these are not standard MIB files, see libsmi2pysnmp(1), smidump(1) and build-pysnmp-mib(1) for all the details.

snmpclient.nodeinfo(oid)

Returns a tuple with symbolic name information for the given object id.

snmpclient.nodename(oid)

Returns the symbolic name for the object id.

snmpclient.nodeid(name)

Returns the node id for the name as a tuple of integers.

The SnmpClient class

This class wraps arround pysnmp's cmdgen.CommandGenerator to make it easier to address an snmp daemon.

snmpclient.SnmpClient(host, port, authorizations)

The constructor takes a hostname/ip address, UDP port and a list of authorization objects.

These objects are created as follows:

SNMP v1, community public
snmpclient.cmdgen.CommunityData('YourApp', 'public', snmpclient.V1)
SNMP v2, custom community
snmpclient.cmdgen.CommunityData('YourApp', 'private123', snmpclient.V2C)
SNMP v3, using a USM user
cmdgen.UsmUserData('snmpuser', 'Password1', 'Password2',
cmdgen.usmHMACSHAAuthProtocol, cmdgen.usmAesCfb128Protocol)

All authorizations in the list are tried until one succeeds. If none succeed, the created instance will have the 'alive' attribute set to False and should not be used.

snmpclient.SnmpClient.get(oid)

Takes a named oid, queries the server and returns the value of that oid on the server.

snmpclient.SnmpClient.gettable(oid)

Takes a named oid, walks that table and returns a list of (oid, value) pairs in that table

snmpclient.SnmpClient.matchtables(index, tables)

Fetches all tables listed in tables and combines returned values according to the index table. If index is None, the index will be autogenerated from the tail of the table OID's. For example, to collect network interface data, one can use:

matchtables('IF-MIB::ifIndex', ('IF-MIB::ifDescr', 'IF-MIB::ifPhysAddress', 'IF-MIB::ifOperStatus'))