Exceptions¶
- class snmp.ErrorStatus¶
This class enumerates the possible error-status values of a PDU. These names correspond to the definitions in RFC 3416, Section 3.
- noError¶
- tooBig¶
- noSuchName¶
- badValue¶
- readOnly¶
- genErr¶
- noAccess¶
- wrongType¶
- wrongLength¶
- wrongEncoding¶
- wrongValue¶
- noCreation¶
- inconsistentValue¶
- commitFailed¶
- undoFailed¶
- authorizationError¶
- notWritable¶
- inconsistentName¶
- exception snmp.ErrorResponse¶
This exception type indicates a non-zero error-status in a Response-PDU.
- property status: ErrorStatus¶
The error-status from the Response-PDU.
- property index: int¶
The error-index from the Response-PDU.
The value of this attribute is guaranteed to be between zero and the length of the
variableBindings(inclusive), even if the value from the Response-PDU is (illegally) outside of that range.
- property variableBindings: VarBindList¶
The
VarBindListfrom the Response-PDU.
- exception snmp.NoSuchName(ErrorResponse)¶
A special case of
ErrorResponseto make it easy for an SNMPv1 application to handlenoSuchNameresponses. Whereas most error-status values indicate an exception, SNMPv1 usesnoSuchNameas part of normal operation. In order to handle the two types separately, theexcept NoSuchNameblock must come first.from snmp import * engine = Engine(SNMPv1) manager = engine.Manager("127.0.0.1") try: vblist = manager.getNext("1.3.7") except NoSuchName as err: if err.index > 0: vb = err.variableBindings[err.index-1] print(f"noSuchName: {vb.name}") else: print("Caught NoSuchName") except ErrorResponse as err: print(f"Error: {err.status.name}") else: print(vblist)
- property status: ErrorStatus¶
This value will always be
ErrorStatus.noSuchName.
- property index: int¶
- property variableBindings: VarBindList¶
- exception snmp.Timeout¶
This exception type indicates that a request has expired without a valid response.
- exception snmp.ImproperResponse¶
This exception type indicates that the variable-bindings of a Response-PDU do not constitute a valid response to the request. For example, if a Get request contains two OIDs, and the Response-PDU returns the two variables in the wrong order, then the
SnmpManager.get()method (or theRequestHandle.wait()method) will raise this error.- property variableBindings: VarBindList¶
The list of variable bindings from the Response-PDU.