Skip to content

mikebryant/python-snormpy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, communities)

The constructor takes a hostname/ip address and a list of community info dicts. These dicts can have the following keys:

name
The security name to use. Almost always ignored, defaults to snmpclient
community
The snmp community to use, defaults to public
version
The snmp version to use. Should be snmpclient.V1 or snmpclient.V2C (default)
port
The port the snmpd should listen on, defaults to 161

All communities 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.set(oid, value)

Takes a named oid, queries the server and sets the value of that oid on the server to the given value.

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'))

About

Wrapper around pysnmp4 for easier snmp querying

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%