PySNMP Project Logo

Project diary
Documentation
Examples
License
Download
Mailing lists

Projects using PySNMP
TwistedSNMP
Zenoss


Relevant projects
SNMPy
YAPSNMP
LibSMI
Scotty software

SourceForge Logo

PySNMP 1.x example applications

The following example scripts are based on various services provided by the pysnmp module.

  • The snmpget.py script takes SNMP agent name, SNMP community name as well as one or more SNMP Object IDs and reports the values associated with given Object IDs as fetched from SNMP agent.
  • The snmpset.py script takes SNMP agent name, SNMP community name as well as one or more SNMP Object IDs & associated values pairs. Then the script tries to SET given Object IDs at SNMP agent to specified values. Upon successful completion, this tool reports new values as set at SNMP agent.
  • The snmpwalk.py script takes SNMP agent name, SNMP community name and SNMP Object ID. Then the script fetches all the lexicographically larger Object IDs from SNMP agent in a one-by-one fashion and reports them along with their associated values.
  • The snmpbulk.py script takes SNMP agent name, SNMP community name as well as one or more SNMP Object IDs. Then the script polls SNMP agent for all the specified Object IDs virtually simultaneously and report them along with their associated values.

    This tool is to demonstrate the use of pysnmp.multisession() class which is designed to poll large number of SNMP agents in the same time (collecting accounting data from many routers is an example).

  • The async_snmpget.py script implements a simple Telnet like server that interacts with user via command line. User instructs server to poll arbitrary SNMP agent and report back to user when SNMP reply is received. Server may poll a number of SNMP agents in the same time as well as handle a number of user sessions simultaneously.

    This script demonstrates the use of asynsnmp.async_session() class designed to ease the binding of SNMP engine with a Python application built around asynchronous I/O core (asyncore).

  • The snmptrap.py script acts as a SNMP trap agent. It takes the name of SNMP manager (trap server), SNMP community name as well as a few SNMP trap specific items (such as trap types, uptime value etc.), builds SNMP trap message and sends it to SNMP trap server.

    According to SNMP trap specification (RFC 1157), SNMP manager is not expected to respond anything back to SNMP agent process upon trap message receiption.

  • The snmptrapd.py script acts as a SNMP manager (trap server). It takes a UDP port number (default is 162) to listen at and SNMP community name. Upon invocation, this script binds to a UDP port specified and waits for SNMP trap messages coming from network.

    Upon trap message receiption, the script parses out the payload from SNMP trap message received and prints it to stdout.

The above scripts are taken from PySNNP package. For more example tools, please, refer to examples/ directory of PySNMP distribution.


Need help? Try PySNMP mailing lists.