Monitor and manage information on a network entity
snmptest [-d] [-p port] [-r retry] [-t timeout] -v 1 host community snmptest [-d] [-p port] [-r retry] [-t timeout] [-v 2] host noAuth snmptest [-d] [-p port] [-r retry] [-t timeout] [-v 2] host srcparty dstparty context
The snmptest utility enables you to monitor and manage information on a network entity using SNMP (Simple Network Management Protocol). There are two different versions of SNMP commonly in use: SNMPv1 and SNMPv2; future versions are planned.
In SNMP terms, a server is called an agent and a client is called a manager. Agents and managers exchange network information using protocol data units (PDUs). The manager sends a PDU requesting information to the agent; the agent responds by retrieving the information from the network's management information database (MIB) and sending a response PDU back to the manager. The manager can also request changes to MIB data or ask for automatic log traps by sending the agent different PDUs.
The snmptest utility provides an interactive facility for generating PDUs from the SNMP manager's command line.
You start an agent by running snmpd on a machine in your network.
You start an interactive manager session by invoking snmptest, after which, the utility prompts you with:
Variable:
This starts your interactive session. You can enter one or more variable names, one per line. If you enter a blank line, snmptest sends a request for each of the variables (in a single packet) to the network entity. See the file mib.txt for the format specification of variable names.
For example for SNMPv1, you might enter:
snmptest -v 1 netdev-kbox.cc.cmu.edu public
or for SNMPv2:
snmptest netdev-kbox.cc.cmu.edu manager_party agent_party agent_context
If you had access to this host, you would get a prompt like this:
Variable:
Now, if you respond like this:
Variable: system.sysdescr.0 Variable:
After you enter the blank line, if your request was successful, snmptest will tell you that is has received a Get Response and will display information about the system.sysdescr.0 object.
By default, snmptest sends a GET request PDU but you can change this at the Variable: prompt by entering a $ command, as follows:
Enter this command: | To: |
---|---|
$B | Send a GetBulkRequest-PDU |
$D | Toggle the dumping of each sent and received packet |
$G | Send a GetRequest-PDU |
$I | Send an InformRequest-PDU |
$N | Send a GetNextRequest-PDU |
$Q | Quit the utility |
$S | Send a SetRequest-PDU |
$T | Send an SNMPv2-Trap-PDU |
Here's a brief explanation of the PDUs:
Variable: $B Request type is Bulk Request Enter a blank line to terminate the list of non-repeaters and to begin the repeating variables Variable: system.sysDescr.0 Variable: Now input the repeating variables Variable: 3 Variable: What repeat count? 4 Received Get Response from 10.7.0.55 requestid 0x7C81 errstat 0x0 errindex 0x0 system.sysObjectID.0 = OID: enterprises.QNX-Systems.1.1 at.atTable.atEntry.atIfIndex.1.1.10.0.2.51 = 1 at.atTable.atEntry.atIfIndex.1.1.10.7.0.55 = 1 at.atTable.atEntry.atPhysAddress.1.1.10.0.2.51 = Hex: 00 E0 29 34 6E 4D at.atTable.atEntry.atPhysAddress.1.1.10.7.0.55 = Hex: 00 01 02 C1 8C 40 Variable:There are a few things to notice about this example session:
Variable: $S Request type is Set Request Variable: system.sysName.0 Type [i|s|x|d|n|o|t|a]: s Value: James Bond Variable: Received Get Response from 10.7.0.55 requestid 0x6EC5 errstat 0x0 errindex 0x0 system.sysName.0 = "James Bond" Variable:
In this session, we are requesting a change in the system name recorded in the MIB database on the agent machine. As long as we have permission to do this, snmptest asks for the variable we want to change, the type of data (a string in this case), and the new value. After we have entered the obligatory blank line, the object is changed and the new value is returned.
Before you can send this PDU, you have to invoke snmptrapd on the machine running the agent. |
If you enter $I, $S, or $T, snmptest requests information about each variable. First, it prompts you for the variable type:
Type [i|s|x|d|n|o|t|a]:
If the variable is: | Enter: |
---|---|
integer | i |
string | s |
hex string | x |
decimal string | d |
null | n |
object id | o |
timeticks | t |
ip address | a |
After you enter a character, snmptest prompts you for a value:
Value:
For this variable type: | Enter: |
---|---|
integer | Integer in decimal. |
ipaddress | IP address in the standard internet dot notation. |
object id | Object ID in dotted numeric notation. |
string | Whitespace-delimited decimal numbers, one per byte of the string. |
timeticks | Integer in decimal. |
If you're using SNMP version 2, the following files must be configured on the machine running the agent:
This ID:
system.syscontact.0
is printed as:
syscontact.0
This ID:
udp.udpTable.udpEntry.udpLocalAddress.0.0.0.161
is printed as:
udpLocalAddress.0.0.0.161
snmpd, snmpget, snmpgetnext, snmpnetstat, snmpset, snmpstatus, snmptranslate, snmptrap, snmptrapd, snmpwalk
/etc/acl.conf, /etc/context.conf, /etc/mib.txt, /etc/party.conf, /etc/snmpd.conf, /etc/view.conf files
RFC 1065, RFC 1066, RFC 1067
RFC 1441, RFC 1445, RFC 1446
RFC 1448, RFC 1449
Marshall T. Rose, The Simple Book: An Introduction to Internet Management, Revised 2nd ed. (Prentice-Hall, 1996, ISBN 0-13-451659-1)