-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception EasySNMPUnknownObjectIDError raised for an OID that exists #15
Comments
I have found the offending code and I'm working on a patch. First, this line is a problem since So I patched in the following function and fixed up the lines as follows: /* returns 1 if None object, 0 if not None, and -1 if error */
static int py_netsnmp_attr_is_none_object(PyObject *obj, char *attr_name)
{
int retval = -1;
if (obj && attr_name)
{
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr)
{
/* 1 if Py_None or 0 otherwise */
retval = (attr == Py_None);
Py_DECREF(attr);
}
}
return retval;
}
/* [...] */
while (varlist_iter && (varbind = PyIter_Next(varlist_iter)))
{
if (py_netsnmp_attr_string(varbind, "oid", &tag, NULL) < 0 ||
(!py_netsnmp_attr_is_none_object(varbind, "oid_index") &&
py_netsnmp_attr_string(varbind, "oid_index", &iid, NULL) < 0)
)
/* [...] */ However now I'm getting a segfault here at this line: if (iid && *iid && oid_arr_len)
{
__concat_oid_str(oid_arr, oid_arr_len, iid);
}
return rtp; Presumably, $ python test_easysnmp.py
([<SNMPVariable value=None (oid='1.3.6.1.4.1.2021.11.53.0', oid_index=None, snmp_type=None)>], True)
[<SNMPVariable value='444734235' (oid='iso.3.6.1.4.1.2021.11.53.0', oid_index='', snmp_type='COUNTER')>] I'll work on a thorough patch that validates this. I'm surprised this isn't picked up by the unit tests. |
Actually, just looking at the successful output from my last response, it appears that the Let me know your insight. Thanks. |
@nnathan Thought I would mention that if you add the leading '.' to the oid the exception is not raised.
|
I haven't investigated the code yet, but I found the following bug in easysnmp.
I have installed the stock SNMP agent with the default configuration.
I fetch a single OID using
snmpget
command:Now, when I use
easysnmp
with the following script:I get the following exception:
So the
easysnmp.interface
is raising the exception except the OID itself does exist as demonstrated by the abovesnmpget
command.The text was updated successfully, but these errors were encountered: