-
Notifications
You must be signed in to change notification settings - Fork 24
The gem does not recognize a missing OID #65
Comments
The debug from the gem:
|
hi @jinxka , Can you run the example above with |
Hi @HoneyryderChuck , Thanks for the quick response, here is the payload:
|
Ok, so if I interpret this correctly, you send the "1.3.6.1.4.5.4.2.3" OID, and expect smth else than 0 (0 here probably meaning, "nothing is defined"). I believe this is a corner case which will be difficult to resolve due to the relative limited capabilities of So I assume that, if you inspect the mib file for "iso.3.6.1.4.5.4.2.3", you'll see the object definition stating that the response should return an IPAddress (feel free to paste it here for documentation purposes). So I think you can workaround it by testing the returned value type, if you know it must be an IP Address: val = test.get(oid: '1.3.6.1.4.5.4.2.3')
raise "no ip" unless val.is_a?(IPAddr) I could provide this check as a "feature", i.e.: val = test.get(oid: '1.3.6.1.4.5.4.2.3', value_type: :ipaddress) # would raise exception unless ipaddress ASN type would be returned But doesn't look very valuable, considering that the workaround is quite short to write. The real improvement would be to put in the time to improve the MIB parser in order to collect Object types information that could be used for validation purposes, unfortunately I don't have the time to work on it (writing the existing MIB parser was already quite involved as is). |
Hello, I did some research and the usual error ruby-netsnmp/lib/netsnmp/varbind.rb Line 118 in 5ee6894
I tested the gem with a "valid" device (which raises an error when retrieving a non-existent oid) and the With the "faulty" device, the method receives: I don't think the method I propose to add a validation in the method to check the value and raise an error like @HoneyryderChuck What do you think? |
ok, I see now. They're both faulty, i.e. the first one should have also raised the same error instead of "error parsing IPAddress". For documentation sake, netsnmp only does what the rfc mandates, i.e. for application-specific OID data:
so 0 means ipaddress, 1 means counter32. However, since both come "empty", both are wrong, and the error you mention should then be raised if there's nothing to unpack. Could you then submit a patch for it? I think it's fine. |
released |
Hello,
I've crossed an issue with one of my device where the gem does not understand that the OID is missing while the
snmpget
command does.Instead of raising the usual
IPAddr::AddressFamilyError
, the gem detects anInteger:0
. This is problematic for me because I use the presence/absence of specific OIDs to detect the type of product I'm dealing with.The debug from
snmpget
We are also able to give you an access to one of our test environment, if you can help us with this issue.
The text was updated successfully, but these errors were encountered: