SNMP (Simple Network Management Protocol) is a networking protocol used to monitor and control network-attached devices such as adapters, routers, switches, workstations, and servers. To use SNMP to communicate with a device, the device must both support SNMP and have SNMP enabled. The primary functions that can be performed through SNMP are device identification, device property querying and device configuration. Since SNMP can be integrated with ATEasy, a technician using ATEasy can automate the testing of SNMP-enabled devices.
In this guide, we will discuss two ways to utilize SNMP within ATEasy:- Using the WinSNMP API with the ATEasy SNMP.drv driver
Using 3rd party software
There are a few open-source SNMP Managers available to utilize for basic testing. This example will demonstrate using Net-SNMP. When installed, Net-SNMP adds command-line executables such as the SNMPGET, SNMPGETNEXT, and SNMPSET functions for OID querying, SNMPWALK for device location, and SNMPSTATUS and SNMPNETSTAT for device status information. Only a couple of these features will be used in the article for demonstration. The complete list of features is available on the Net-SNMP webpage.
The example below demonstrates calling the executable SNMPGet to query an OID for information and saving the results to a text file.
Procedure SNMPGet(): Void
--------------------------------------------------------------------------------
sAgent: String
sSaveFile: String
sOID: String
sCommunity: String
{
sCommunity = "public"
sAgent = "127.0.0.1" ! Local Host
! Object Identifier Descriptor for the device we're talking with
sOID = "sysDescr.0"
sSaveFile = "snmpgetresults.txt"
! Calls device SNMP and saves results to text file
WinExec("SNMPGET -v 1 -c " + sCommunity + " " + sAgent + " " + sOID + " > " \
+ sSaveFile)
! display results
WinExec("notepad " + sSaveFile) ! Opens text file for viewing the SNMPGET results
}
In the first WinExec command an OID, sysDescr.0, is requested from the local host and saved into "snmpgetresults.txt". The second WinExec command opens that file so the data can be viewed.
The SNMPGet procedure can be modified to use the other Net-SNMP features, such as SNMPNETSTAT which gives us the assignment of an agent's TCP and UDP ports.
Using the ATEasy v8.0 WinSNMP Driver
Another way to communicate with a target agent using SNMP protocol is to directly access the WinSNMP API provided with Microsoft Windows. The implementation is simplified through use of the WinSNMP ATEasy driver, which is available in ATEasy v8.0 and above. The driver also lists the procedure to install and configure the WinSNMP service required when using the Windows driver.
In the ATEasy implementation of WinSNMP, an SNMPGET call can request and retrieve the value of an Object Identifier in a single command, as shown here:
! Request the System Contact from the agent
TestResult = SNMP Function Get("1.3.6.1.2.1.1.5.0")
With the ATEasy Driver included in the project, the preceding line of code acquires the System Contact octet string and assigns it back to the TestResult variable for use in ATEasy.
Similarly, the included function "SNMP Function Walk(...)" can be used to traverse a system and returns back all of the nodes between the start and stop OID specified.
!Return the data stored at all OIDs between 1.3.6.1.2.1 and 1.3.6.1.2.1.6.0
TestResult = SNMP Function Walk("1.3.6.1.2.1", "1.3.6.1.2.1.1.6.0")
Example results of an SNMP Walk:
1.3.6.1.2.1 = NULL: 0
1.3.6.1.2.1.1.1.0 = STRING: Hardware: x86 Family 15 Model 4 Stepping 7 AT/AT COMPATIBLE
1.3.6.1.2.1.1.3.0 = TIMETICKS: 52335668
1.3.6.1.2.1.1.4.0 = STRING: Victor Brode
1.3.6.1.2.1.1.6.0 = STRING: My CTS box
Summary
This demonstration of features just barely scratches the surface of the utility that SNMP provides. A complete listing of the WinSNMP ATEasy driver is available in ATEasy v8.0 and above. Hopefully, if your project is required to automate SNMP communication, this article has given you a good idea where to start.