lextudio / sharpsnmplib

Sharp SNMP Library- Open Source SNMP for .NET
https://sharpsnmp.com
MIT License
356 stars 152 forks source link

problem with get_table and get_bulk #513

Closed lextudio-support closed 3 hours ago

lextudio-support commented 3 hours ago

Hi,

I have a problem with two sample programs from sharpsnmplib - 37414 - testgettable and testgetbulk. I want to get some info from my cisco router using snmp. Testget and testgetnext programs work excellent, but when i use testgettable i get exception:

when i trying to compile this code:

IPAddress ip;
bool parsed = IPAddress.TryParse("192.168.1.10", out ip);
Variable[,] table = Messenger.GetTable(VersionCode.V1, new IPEndPoint(ip, 161), new OctetString("lucas"),
                                       new ObjectIdentifier(new uint[] { 1, 3, 6, 1, 2, 1, 2, 2 }), 5000, 10, DefaultObjectRegistry.Instance);

I get exception "not a table OID: .1.3.6.1.2.1.2.2" and i am redirected to this part of code from Messenger.cs file:

bool canContinue = registry == null || registry.ValidateTable(table);
            if (!canContinue)
            {
                throw new ArgumentException("not a table OID: " + table);
            }

Next issue is testgetbulk. When i compile it with parameters: -c=lucas 192.168.1.10 1.3.6.1.2.1.2.2 i get "lextm.sharpsnmplib.messaging.timeoutexception" and i have no idea why.

For me it doesn't work with any OID number so OID cannot be a problem...

Next issue is testgetbulk. When i run it with parameters: -c=lucas 192.168.1.10 1.3.6.1.2.1.2.2, i get "lextm.sharpsnmplib.messaging.timeoutexception" and i have no idea why. (maxRepetitions = 10, nonRepeaters = 0, timeout = 2000 -> i have tried changing these parameters but without success).

Router's snmp agent is ok. I checked the same snmp functions (with the same parameters) using another mib browser and it worked fine.

I use visual studio 2008.

Thanks for any help.

Original Reported Date: 2010-03-04T05:42:20.433-08:00 Original CodePlex Discussion Thread ID: 203786

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

The first question is easy to answer, as you can simply replace DefaultObjectRegistry.Instance with null. If you don't specify an object registry the OID validation process will be skipped and the exception will not be there.

For the second question, appreciated if you can share with me the network capture (Microsoft Network Montior or Wireshark).

Regards,

Lex

Original Posted Date: 2010-03-04T19:00:59.063-08:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

I am very grateful for help. I used the network capture to compare messages created by testgetbulk and the other MIB browser and they differed in version of SNMP - it should be SNMP 2 or higher (in testgetbulk there is SNMP 1 by default and it was a problem).

Regards

Original Posted Date: 2010-03-05T03:40:27.4-08:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

"in testgetbulk there is SNMP 1 by default and it was a problem"

I will see to it and fix the problem.

Thanks for reporting it.

Lex

Original Posted Date: 2010-03-05T16:59:37.753-08:00

lextudio-support commented 3 hours ago

Marked as Answer Date: 2013-10-06T20:53:29.45-07:00