|
Methods defined here:
- __init__(self, ip, port=161, community='public', snmpVersion='1', protocol=None, allowCache=False)
- Initialize the SNMPProtocol object
ip -- ipAddress for the protocol
port -- port for the connection
community -- community to use for SNMP conversations
snmpVersion -- '1' or '2', indicating the supported version
protocol -- SNMPProtocol object to use for actual connection
allowCache -- if True, we will optimise queries for the assumption
that we will be sending large numbers of identical queries
by caching every request we create and reusing it for all
identical queries. This means you cannot hold onto the
requests, which isn't a problem if you're just using the
proxy through the published interfaces.
- __repr__(self)
- Get nice string representation of the proxy
- cacheOIDEncoding = berInternEncoding(cls, oid) from __builtin__.classobj
- Given an OID value, cache the BER encoded values for reference
- dispatchTrap(self, message)
- Dispatch incoming trap message to any registered watchers...
- encode(self, oids, community, next=0, bulk=0, set=0, maxRepetitions=128, allowCache=True)
- Encode a datagram message
oids -- list of OID instances (where set is False) to be retrieved
*or*
list of (OID,value) instances to be assigned
community -- community string for the query/set
next -- whether this is to be a getnext query
bulk -- whether this is to be a getbulk query
maxRepetitions -- max number of repeating values for getbulk
allowCache -- if True, and self.allowCache and not set,
then we will store and re-use request objects. allowCache is
used by the tabular retrieval code to avoid caching queries
beyond the first, as these are likely to be highly variable.
- get(self, oids, timeout=2.0, retryCount=4)
- Retrieve a single set of OIDs from the remote agent
oids -- list of dotted-numeric oids to retrieve
retryCount -- number of retries
timeout -- initial timeout, is multipled by 1.5 on each
timeout iteration.
return value is a defered for an { oid : value } mapping
for each oid in requested set
XXX Should be raising an error if the response has an
error message, will raise error if the connection times
out.
- getImplementation(self)
- Get the implementation module for this request
returns v2c or v1 pysnmp modules depending on our
snmpVersion property.
- getRequestKey(self, request)
- Get the request key from a request/response
- getResponseResults(self, response)
- Get [(oid,value)...] list from response
This callback is part of the callback chain for get
response processing. In essence, if you have a callback
that wants [(oid,value)...] format instead of response
objects register this callback before the needy callback.
- getTable(self, roots, includeStart=0, recordCallback=None, retryCount=4, timeout=2.0, maxRepetitions=128, startOIDs=None)
- Convenience method for creating and running a TableRetriever
roots -- root OIDs to retrieve
includeStart -- whether to include the starting OID
in the set of results, by default, return the OID
*after* the root oids.
Note: Only implemented for v1 protocols, and likely
to be dropped eventually, as it seems somewhat
superfluous.
recordCallback -- called for each new record discovered
recordCallback( root, oid, value )
retryCount -- number of retries
timeout -- initial timeout, is multipled by 1.5 on each
timeout iteration.
maxRepetitions -- size for each block requested from the
server, i.e. how many records to download at a single
time
startOIDs -- optional OID markers to be used as starting point,
i.e. if passed in, we retrieve the table from startOIDs to
the end of the table excluding startOIDs themselves, rather
than from roots to the end of the table.
Will use bulk downloading when available (i.e. if
we have implementation v2c, not v1).
return value is a defered for a { rootOID: { oid: value } } mapping
- listenTrap(self, ipAddress=None, genericType=None, specificType=None, community=None, callback=None)
- Listen for incoming traps, direct to given callback
ipAddress -- address from which to allow messages
genericType, specificType -- if present, only messages with the given
type are passed to the callback
community -- if present, only messages with this community string are
accepted/passed on to the callback
callback -- callable object to register, or None to deregister
- send(self, request)
- Send a request (string) to the network
- set(self, oids, timeout=2.0, retryCount=4)
- Set a variable on our connected agent
oids -- dictionary of oid:value pairs, or a list of
(oid,value) tuples to be set on the agent
raises errors if the setting fails
Static methods defined here:
- resolveVersion(value)
- Resolve a version specifier to a canonical version and an implementation
Data and other attributes defined here:
- CACHE = {}
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'AgentProxy' objects>
- list of weak references to the object (if defined)
- verbose = 0
|