PowerSNMP for .NET | Get Request Code Example

See all PowerSNMP for .NET Code Examples

Get Request Example

This example demonstrates sending a Get request and receiving the response.

 

//Create Manager, and Socket to send request from
Manager manager1 = new Manager();
SnmpSocket managerSocket = new SnmpSocket(manager1);

//Create Get Request
GetMessage request = new GetMessage();
request.Variables.Add(manager1.Mib.CreateVariable(NodeName.sysContact));
//Or by IID: request.Variables.Add(manager1.Mib.CreateVariable(new Variable("1.3.6.1.2.1.1.4.0"));

//Optionally use version 3. Set username and passwords.
request.Version = SnmpVersion.Three;
request.Security.User.Name = "testAuthPriv";
request.Security.User.AuthenticationProtocol = AuthenticationProtocol.Md5;
request.Security.User.AuthenticationPassword = "dartauth";
request.Security.User.PrivacyProtocol = PrivacyProtocol.Des;
request.Security.User.PrivacyPassword = "dartpriv";

//Send request and get response
ResponseMessage response = managerSocket.GetResponse(request, new Dart.Snmp.IPEndPoint("myAgentAddress", Agent.DefaultPort));

//Display the value
Console.WriteLine(response.Variables[0].ToString());

 

To download a trial please visit the PowerSNMP for .NET product page.