The pysnmp package contains a few modules that collectively implement various kinds of SNMP engines suitable for building SNMP managers and agents. For more information on SNMP protocol, see RFC 1157, RFC 1155 and RFC 1213.
Here is an example of how PySNMP can be used.
Python 1.5.2 (#3, Aug 25 1999, 19:14:24) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from pysnmp import session >>> s = session.session ('router-1.glas.net', 'public') >>> encoded_objid = s.encode_oid ([1, 3, 6, 1, 2, 1, 1, 1, 0]) >>> question = s.encode_request ('GETREQUEST', [encoded_objid], []) >>> answer = s.send_and_receive (question) >>> (encoded_objids, encoded_values) = s.decode_response (answer) >>> objids = map (s.decode_value, encoded_objids) >>> objids ['.1.3.6.1.2.1.1.1.0'] >>> values = map (s.decode_value, encoded_values) >>> values ['Cisco Internetwork Operating System Software \015\012IOS (tm) 5300 Software (C5300-J-M), Experimental Version 12.1(20001115:152556) [haag-V121_4 102] \015\012Copyright (c) 1986-2000 by cisco Systems, Inc.\015\012Compiled Mon 20-Nov-00 19:22 by haag'] >>>
Below is the documentation on the SNMP engine modules supplied with pysnmp package:
The following documentation is devoted to Basic Encoding Rules (BER) engine used for building and parsing SNMP message and its components:
The PySNMP components may raise package specific exceptions on API error, BER, SNMP engines or remote SNMP process failures.