snmptest

Monitor and manage information on a network entity

Syntax:

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

Runs on:

Neutrino

Options:

-d
Dump input and output packets.
-p port
Specify the destination port number.
-r retry
Specify the number of retries.
-t timeout
Specify the timeout (in seconds).
-v 1|2
SNMP version (default is 2).
community
The community name for the transaction with the remote system.
context
The collection of object resources that can be queried by the dstparty.
dstparty
The name of the party providing information.
host
An Internet address specified in dot notation or a host name.
srcparty
The name of the party requesting information.

Description:

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:

GetBulkRequest-PDU ($B)
This returns information on several objects. You first specify any individual objects you are interested in, then a number corresponding to a particular object group, then the number of objects within that group you want to see. This is how such a session might go:
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 sample session:
GetRequest-PDU ($G)
This is the default PDU. It asks the agent to send information about a network entity. The agent responds with a Response-PDU containing the information requested. For more information, see snmpget.
InformRequest-PDU ($I)
An SNMP manager uses this type of PDU to inform other managers about MIB information hidden from their view. An inform request is similar to a trap in that it can be used to send notification of an event that has occurred but, unlike a trap, an inform request is always acknowledged. This makes it a more reliable way of sending notifications than a trap, but also more expensive in terms of network resources.
GetNextRequest-PDU ($N)
This is similar to the GetRequest-PDU but it requests the next object in the MIB database.
SetRequest-PDU ($S)
This PDU changes objects in the MIB database on the agent machine. Such a session might go like this:
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.

SNMPv2-Trap-PDU ($T)
Managers use this PDU to request an agent to report events asynchronously. When the specified events occur, the agent sends a trap to the requesting manager.

Note: 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:

Environment variables:

MIBFILE
Specify the location of the mib.txt file. For example, MIBFILE=path/mib.txt (the default path is /etc).
SUFFIX
If SUFFIX exists in your environment, all object IDs with a symbolic name are printed with only the last element. Examples:

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
      

See also:

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)