#!/usr/local/bin/python -O """ Retrieve a subtree of lexicographically greater Object IDs starting from user specifed SNMP Object ID from arbitrary SNMP agent. Since MIB parser is not yet implemented in Python, this script takes and reports Object IDs in dotted numeric representation only. Written by Ilya Etingof , 2000-2002 """ import sys import getopt # Import PySNMP modules from pysnmp import asn1, v1, v2c from pysnmp import role # Initialize help messages options = 'Options:\n' options = options + ' -p port to communicate with at the agent. Default is 161.\n' options = options + ' -r number of retries to be used in requests. Default is 5.\n' options = options + ' -t timeout between retries. Default is 1.\n' options = options + ' -v SNMP version to use [1, 2c]. Default is 1 (version one).' usage = 'Usage: %s [options] ' + str(val) # BER encode next SNMP Object IDs to query encoded_oids = map(asn1.OBJECTID().encode, oids) # Update request object req['request_id'] = req['request_id'] + 1 # Switch over GETNEXT PDU for if not done if not (req is nextReq): req = nextReq