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 softwareThere 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
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 + " > " \
! 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 DriverAnother 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("220.127.116.11.18.104.22.168.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 22.214.171.124.2.1 and 126.96.36.199.188.8.131.52
TestResult = SNMP Function Walk("184.108.40.206.2.1", "220.127.116.11.18.104.22.168.0")
Example results of an SNMP Walk:
22.214.171.124.2.1 = NULL: 0
126.96.36.199.188.8.131.52.0 = STRING: Hardware: x86 Family 15 Model 4 Stepping 7 AT/AT COMPATIBLE
184.108.40.206.220.127.116.11.0 = TIMETICKS: 52335668
18.104.22.168.22.214.171.124.0 = STRING: Victor Brode
126.96.36.199.188.8.131.52.0 = STRING: My CTS box
SummaryThis 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.