PowerSNMP for .NET | SNMP Agent Code Example
See all PowerSNMP for .NET Code Examples
SNMP Agent Example
This example demonstrates initiating an Agent and listening for and responding to SNMP queries (Sets, Gets, etc).
private void Form_Load(object sender, EventArgs e)
{
Agent agent1 = new Agent();
//Add a variable to the agent
agent1.Variables.Add(agent1.Mib.GetByNodeName(NodeName.sysContact).GetIid(), agent1.Mib.CreateVariable(NodeName.sysContact, "Systems Admin"));
//Start listening for requests
agent1.Start(agent1_MessageReceived, null);
}
private void agent1_MessageReceived(Agent agent, RequestMessage request, object state)
{
//Create and send a response whenever a request is received
agent.Send(agent.CreateResponse(request), request.Origin);
}
To download a trial please visit the PowerSNMP for .NET product page.