I am trying to integrate into SNMP scanning with my application and have delved into Google to try and find examples, etc. I have thus come across the SNMPSharpNet DLL which has allowed me to start contacting devices using SNMP which is from this website.
However, I have two issues that are similary related:
I tried to refer to this website to determine what oID to use when trying to scan a Cisco Catalyst 2960 Switch but it returned nothing (no errors and no results). The only way I could get it to work correctly (pull everything) was to use an oID of 1. This then sets off to pull back everything out of the switch, so I could then use it as a reference to determine specific oIDs for specific required data.
Which leads me to my next question.... using an oID of 1 does seem to work, however, part way through it errors out with "The agent responded with an error" which doesn't really tell me anything. I get it everytime with attempting SNMP on different devices and it's not pulling back all of the data.
My code looks like this:
Sub GetNextResult()
Dim host As String = "xx.xx.xx.xx"
Dim community As String = "public"
Dim requestOid() As String
Dim result As Dictionary(Of Oid, AsnType)
Dim rootOid As Oid = New Oid("1")
Dim nextOid As Oid = rootOid
Dim keepGoing As Boolean = True
requestOid = New String() {rootOid.ToString()}
Dim snmp As SimpleSnmp = New SimpleSnmp(host, community)
snmp.SuppressExceptions = False
If Not snmp.Valid Then
Console.WriteLine("Invalid hostname/community.")
Exit Sub
End If
While keepGoing
result = snmp.GetNext(SnmpVersion.Ver1, New String() {nextOid.ToString()})
If result IsNot Nothing Then
Dim kvp As KeyValuePair(Of Oid, AsnType)
For Each kvp In result
If rootOid.IsRootOf(kvp.Key) Then
Console.WriteLine("{0}: ({1}) {2}", kvp.Key.ToString(), _
SnmpConstants.GetTypeName(kvp.Value.Type), _
kvp.Value.ToString())
nextOid = kvp.Key
Else
keepGoing = False
End If
Next
Else
Console.WriteLine("No results received.")
keepGoing = False
End If
End While
End Sub
I guess my question is: Is there some sort of reference I could refer to get a list of the different oIDs required for specific information? Or if not, can I continue to use an oID of 1 and try to fix why it continually errors out with a generic error?
Any help appreciated thanks.