SNMP MIB Browser Software Development Kit for ColdFusion for Windows

ActiveSocket is a Network Communication component for Windows Developers. It runs on any 32 bit and 64 bit Windows Platform, incl. Windows 7, Windows 2008, Windows 2003, Windows 2000, Windows Vista and Windows XP.
It features many IP protocols, incl.: SSH (Secure Shell), RSH (Remote Shell), HTTP(s), FTP, ICMP Ping, NTP, SNMP v1/v2c (Get,GetNext,Set), SNMP MIB translation, SNMP Trap Sender, SNMP Trap Receiver, Telnet, DNS, TCP, UDP, IP-to-Country, Wake-On-LAN and more. Samples are included many popular development platforms, incl. Visual C# .NET, Visual Basic .NET, ASP .NET, Visual Basic, Visual C/C++, ASP, Java, Javascript, PHP, Borland Delphi, Borland C++ Builder, ColdFusion.

SNMP MIB Browsing can be well integrated into ColdFusion environments. This document describes how ActiveSocket's SNMP MIB Browser can be integrated into ColdFusion projects.

A management information base (MIB) is a database used to manage the devices in a communications network. The database is hierarchical (tree-structured) and entries are addressed through object identifiers (OID's). A MIB should contain information on these commands and on the target objects (controllable entities or potential sources of status information) with a view to tuning the network transport to the current needs. Each type of object in a MIB database has a name, a syntax, and an encoding. The name is represented uniquely as an OID. An OID is an administratively assigned name. The administrative policies used for assigning names are discussed later in this memo.

Use ActiveSocket's 'SnmpMibBrowser' object to load a MIB database into memory and iterate over all objects and view all properties.

Step 1: Download and install the ActiveSocket Toolkit

Download ActiveSocket from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new ColdFusion document

Create a new blank webdocument with the ".cfm" extention. First of all we are going to build the form whitch commands and properties of the device can be filled in. Then we are going to make a source code that connects to the device.

Step 3: Implementation

For the usage of SNMP in ColdFusion, we're going to work with objects. Sending an OID to a server is quit simple. It can be done in four simple steps.

  • Make the ActiveSocket object
  • Fill in the properties
  • Connect to the host
  • Send the OID

Attention: Before using this sample, make sure you've configured SNMP properly.

Once the object is created the rest is easy. To make the ActiveSocket object in ColdFusion you need the following code snippet:

 <cfobject class="ActiveXperts.SnmpManager" type="com" name="objSnmp" Action="Create"> 

Trough this tag you are able to communicate trough the ActiveSocket toolkit. The program has a certain amount of options witch are to be found in the products manual that is shipped with it. In our sample just a few of them are used. You can call to a function of the object using a “.”.

We're also going to need a form that collects the required information to send an OID. We've made a form that looks like this:

(Click on the picture to enlarge)

Once the form is ready the first thing we're configuring is the “logfile” option. You can fill in the path and filename for the logfile. Trough this file you’re able to check what goes on during the execution of the script you are writing. Use the following code to configure the logfile:

 <cfset objSnmpManager.LogFile = “C:\temp\logfile.txt”> 

First of all we're going to initialise SNMP. Using "Initialize()":

 <cfset objSnmpManager.Initialize()> 

Then we're moving on to setting the protocol version. We're doing this with the "version" property of the object we have created. Versions can differ between version one and two.

 <cfset objSnmpManager.Version = URL.Version > 

If all of this is succesfully configured, we're able to open a connection to a host. We're able to do that using the "Open()" command. We need to fill in the host, the community and the portnumber.

 <cfset objSnmpManager.Open("localhost", "public", 161) > 

You're able to get an OID using the property "Get("someOid")". This makes the entire sourcecode to send an OID look like this:

function snmpget(getnext, OID){

   objSnmpManager.LogFile = strLogFile;
   objSnmpManager.Initialize();
   objSnmpManager.ProtocolVersion = strVersion;
   
   if(objSnmpManager.LastError eq 0){
      objSnmpManager.Open(strHost,strCommunity,strPort);
   }

   if(objSnmpManager.LastError eq 0){
     objSnmpData = objSnmpManager.get(OID);
     if (getnext eq "getnext") {
       objSnmpData = objSnmpManager.getnext();
     }
	   
   }
	 
   if(objSnmpManager.LastError eq 0){

     strOid = objSnmpData.oid;
     strValue = objSnmpData.value & "<br>";
		 
   }

   strResult = objSnmpManager.LastError & " : " & objSnmpManager.GetErrorDescription(objSnmpManager.LastError);
	 
   objSnmpManager.Close();
   objSnmpManager.Shutdown();	 

}

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/asocket.