Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Wrapper around pysnmp4 for easier snmp querying

License

Notifications You must be signed in to change notification settings

mihailim/python-snormpy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snormpy

A utility library for easier use of pysnmp4.

Utility functions

snormpy.add_mib_path(path)

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

snormpy.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.

snormpy.nodeinfo(oid)

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

snormpy.nodename(oid)

Returns the symbolic name for the object id.

snormpy.nodeid(name)

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

The SnormpyClient class

This class wraps arround pysnmp's cmdgen.CommandGenerator to make it easier to address a SNMP agent.

snormpy.SnormpyClient(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 snormpy
community
The snmp community to use, defaults to public
version
The snmp version to use. Should be snormpy.V1 or snormpy.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.

snormpy.SnormpyClient.get(oid)

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

snormpy.SnormpyClient.set(oid, value)

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

snormpy.SnormpyClient.gettable(oid)

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

snormpy.SnormpyClient.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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%