ActiveSocket is compliant with SNMP versions v1 and v2c. Several SNMP data types are supported, including:
ActiveSocket supports the following SNMP trap features:
ActiveSocket can be well integrated into Visual Basic environments. This document describes how ActiveSocket can be integrated into Visual Basic projects.
IMPORTANT: Make sure that the SNMP Service is installed and running on the machine where ActiveSocket is installed. For more details, please read FAQ items Q1200010 and Q1200015.
Download the ActiveSocket Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Launch 'Microsoft Visual Basic' from the Start menu, and choose 'New' from the 'File Menu'. The 'New Project' dialog appears. Select 'Standard Exe' and click 'OK':
(Click on the picture to enlarge)
A new Project is created, with a blank form.
First, you must add a reference to ActiveSocket in the project to be able to use the object. To do so, choose 'References...' from the 'Project' menu. In the 'References' dialog that pops up, enable the 'ActiveSocket 3.1 Type Library' reference as shown in the following picture:
(Click on the picture to enlarge)
Click 'OK' to close the 'References...' dialog.
To send SNMP traps using Visual Basic, you need to declare and create the following ActiveSocket objects:
From the Code window, select 'Form'. The Private Sub 'Form_Load()' will be displayed now. In the 'Form Load' function, create the objects in the following way:
Set objSnmpTrapManager = CreateObject("ActiveXperts.SnmpTrapManager")
Set objSnmpTrap = CreateObject("ActiveXperts.SnmpTrap")
Set objSnmpObject = CreateObject("ActiveXperts.SnmpObject")
When the required SNMP objects are created, you can implement the code to send a SNMP trap:
Private Sub CommandSend_Click()
' Declare the local SNMP objects
Dim objSnmpTrapa As SnmpTrap
Dim objSnmpObject As SnmpObject
' Create the SNMP objects
Set objSnmpTrap = CreateObject("ActiveXperts.SnmpTrap")
Set objSnmpObject = CreateObject("ActiveXperts.SnmpObject")
' Set the data to be send within this trap (variable bindings)
objSnmpObject.OID = TextOID.Text
objSnmpObject.Type = GetType
objSnmpObject.Value = TextValue.Text
' Set the properties of the Trap object
objSnmpTrap.Clear
objSnmpTrap.Community = TextCommunity.Text
objSnmpTrap.Host = TextAgent.Text
objSnmpTrap.Port = CInt(TextPort.Text)
' Add the data to the trap
objSnmpTrap.AddObject objSnmpObject
' Set the protocol version
objManager.ProtocolVersion = ComboVersion.ListIndex + 1
' Send the trap
objManager.Send objSnmpTrap
' Ready
End Sub
You can download the complete sample from our ftp site ftp.activexperts-labs.com/samples/asocket. There are many other working ActiveSocket scripts on our site and shipped with the product.