SNMP GET request

Namespace:  SnmpSharpNet
Assembly:  SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.5.2.0 (0.5.2.0)

Syntax

C#
public Dictionary<Oid, AsnType> Get(
	SnmpVersion version,
	Pdu pdu
)
Visual Basic (Declaration)
Public Function Get ( _
	version As SnmpVersion, _
	pdu As Pdu _
) As Dictionary(Of Oid, AsnType)
Visual C++
public:
Dictionary<Oid^, AsnType^>^ Get(
	SnmpVersion version, 
	Pdu^ pdu
)

Parameters

version
Type: SnmpSharpNet..::.SnmpVersion
SNMP protocol version. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
pdu
Type: SnmpSharpNet..::.Pdu
Request Protocol Data Unit

Return Value

Result of the SNMP request in a dictionary format with Oid => AsnType values

Examples

SNMP GET request:
CopyC#
String snmpAgent = "10.10.10.1";
String snmpCommunity = "public";
SimpleSnmp snmp = new SimpleSnmp(snmpAgent, snmpCommunity);
// Create a request Pdu
Pdu pdu = new Pdu();
pdu.Type = SnmpConstants.GET; // type GET
pdu.VbList.Add("1.3.6.1.2.1.1.1.0");
Dictionary<Oid, AsnType> result = snmp.GetNext(SnmpVersion.Ver1, pdu);
if( result == null ) {
  Console.WriteLine("Request failed.");
} else {
  foreach (KeyValuePair<Oid, AsnType> entry in result)
  {
    Console.WriteLine("{0} = {1}: {2}", entry.Key.ToString(), SnmpConstants.GetTypeName(entry.Value.Type),
      entry.Value.ToString());
  }
}
Will return:
CopyC#
1.3.6.1.2.1.1.1.0 = OctetString: "Dual core Intel notebook"

See Also