Knowledge Base FAQ Item #1200040
Q1200040: Is possible to define specific and generic traps using Network Component SnmpTrapManager Object?
Yes this is possible. In SNMP V1, there is an extra field in the SNMP PDU, in SNMP V2, the generic trap is represented by an OID. You only have to set the 'GenericTrap' property of the SnmpTrap object as demonstrated in the code snippet below:
Option Explicit ' Declare objects Dim objSnmpTrapManager, objSnmpTrap, objSnmpConstants, objSnmpObject ' Create object Set objSnmpTrapManager = CreateObject ( "ActiveXperts.SnmpTrapManager" ) Set objSnmpTrap = CreateObject ( "ActiveXperts.SnmpTrap" ) Set objSnmpObject = CreateObject ( "ActiveXperts.SnmpObject" ) Set objSnmpConstants = CreateObject ( "ActiveXperts.ASConstants" ) ' Start manager objSnmpTrapManager.Initialize objSnmpTrapManager.ProtocolVersion = objSnmpConstants.asSNMP_VERSION_V2C ' Set trap properties objSnmpTrap.Clear() objSnmpTrap.Host = "192.168.31.98" objSnmpTrap.Community = "public" objSnmpTrap.GenericTrap = objSnmpConstants.asSNMP_TRAP_LINKUP ' Send the trap objSnmpTrapManager.Send objSnmpTrap ' Shutdown the manager objSnmpTrapManager.Shutdown(viewed: 1772)