charlestolley / python-snmp

A user-friendly SNMP library
MIT License
15 stars 3 forks source link

SNMPv1 when the endOfMib is reached, an ErrorResponse is thrown #10

Closed denisbondar closed 6 months ago

denisbondar commented 6 months ago

If the response error-status field is not 0, an ErrorResponse exception is thrown, to which pdu.errorStatus and pdu.errorIndex are passed. But it is impossible to get these two important values from the exception instance.

The need for these values can be caused, for example, by the fact that in SNMPv1, when reaching the end of the tree, the agent passes error-status=2 (endOfMib).

If execute getNext in the loop, at some point you may get an ErrorResponse exception and there is no way to know the value of the error-status field.

Maybe this problem can be solved differently by throwing some EndOfMib exception at manager (v1), because the described problem is typical for SNMPv1.

charlestolley commented 6 months ago

I've added "status" and "cause" attributes to ErrorResponse in the master branch, I need to update the documentation as well. Basically, status will tell you the error-status, and cause will give either the offending VarBind (if error-index is non-zero), or the request PDU itself, if error-index is zero. If by some mistake, error-index is not a valid index, then "cause" will just contain the integer value of error-index.

charlestolley commented 6 months ago

I've updated this in the documentation now as well