PowerSNMP for .NET | Send Trap Code Example
See all PowerSNMP for .NET Code Examples
Send Trap Example
This example demonstrates sending traps.
//Create Agent, and Socket to send Trap from
Agent agent1 = new Agent();
//Set sysObjectId to your enterprise number (for Trap1).
agent1.Variables.Add(agent1.Mib.GetByNodeName(NodeName.sysObjectID).GetIid(), agent1.Mib.CreateVariable(NodeName.sysObjectID, "1.3.6.1.4.1.52222"));
//Send an SNMPv1 Trap
agent1.Send(new Dart.Snmp.Trap1.warmStart(agent1.Variables[agent1.Mib.GetByNodeName(NodeName.sysObjectID).GetIid()].Value.ToString(), agent1.SysUpTime), new Dart.Snmp.IPEndPoint("myManagerAddress", Manager.DefaultPort));
//Send an SNMPv2 Trap (for SNMPv3, configure warmStart.Security.User)
agent1.Send(new Dart.Snmp.Trap2.warmStart(agent1.SysUpTime), new Dart.Snmp.IPEndPoint("myManagerAddress", Manager.DefaultPort));
To download a trial please visit the PowerSNMP for .NET product page.