The z/OS UNIX snmp command

The z/OS UNIX snmp command provides the following SNMP manager functions from the z/OS® UNIX shell:
  • Query SNMP agents for network management information.
  • Receive and format SNMP traps and notifications.

Use the snmp command to issue SNMP requests to agents and to process SNMP responses returned by agents. This command supports a maximum SNMP response packet size of 65 535 bytes. SNMPv1, SNMPv2c, and SNMPv3 requests are supported.

Use the snmp command with the trap request type to receive and format traps and notifications.

Note: snmp is a synonym for the osnmp command in the z/OS UNIX shell. The osnmp command syntax is the same as that for the snmp command.

Format

Getting MIB Variables:

Read syntax diagramSkip visual syntax diagram
         .- -d 0-----------.  .- -h localhost---.   
>>-snmp--+-----------------+--+-----------------+--------------->
         '- -d debug_level-'  '- -h target host-'   

   .- -r 2------------.  .- -c public----------.   
>--+------------------+--+---------------------+---------------->
   '- -r retry number-'  '- - c community_name-'   

   .- -t 3-------------.                     
>--+-------------------+--+-----+--+-----+---------------------->
   '- -t timeout value-'  '- -v-'  '- -a-'   

>--+-get-----------------------------------------------------+-->
   +-getnext-------------------------------------------------+   
   | .- -m 10--------------.  .- -n 0-------------.          |   
   '-+---------------------+--+-------------------+--getbulk-'   
     '- -m max repetitions-'  '- -n non-repeaters-'              

   .--------------.   
   V              |   
>----mib_variable-+--------------------------------------------><

Setting the MIB Variables:

Read syntax diagramSkip visual syntax diagram
         .- -d 0-----------.  .- -h localhost---.   
>>-snmp--+-----------------+--+-----------------+--------------->
         '- -d debug_level-'  '- -h target host-'   

   .- -r 2------------.  .- -c public---------.   
>--+------------------+--+--------------------+----------------->
   '- -r retry number-'  '- -c community_name-'   

   .- -t 3-------------.                          
>--+-------------------+--+-----+--+-----+--set----------------->
   '- -t timeout value-'  '- -v-'  '- -a-'        

   .----------------------------------.   
   V                                  |   
>----mib_variable--+---------+--value-+------------------------><
                   '-vartype-'            

Walking the MIB Tree:

Read syntax diagramSkip visual syntax diagram
         .- -d 0-----------.  .- -h localhost---.   
>>-snmp--+-----------------+--+-----------------+--------------->
         '- -d debug_level-'  '- -h target host-'   

   .- -r 2------------.  .- -c public---------.   
>--+------------------+--+--------------------+----------------->
   '- -r retry number-'  '- -c community_name-'   

   .- -t 3-------------.                     
>--+-------------------+--+-----+--+-----+---------------------->
   '- -t timeout value-'  '- -v-'  '- -a-'   

>--+-walk-----------------------------------------------------+-->
   | .- -m 10--------------.  .- -n 0-------------.           |   
   '-+---------------------+--+-------------------+--bulkwalk-'   
     '- -m max repetitions-'  '- -n non-repeaters-'               

>--mib_variable------------------------------------------------><

Displaying snmp Help:

Read syntax diagramSkip visual syntax diagram
>>-snmp-- -?---------------------------------------------------><

Receiving a Trap:

Read syntax diagramSkip visual syntax diagram
         .- -d 0-----------.  .- -p 162---------.         
>>-snmp--+-----------------+--+-----------------+--trap--------><
         '- -d debug_level-'  '- -p port_number-'         

Finding a MIB Variable Name:

Read syntax diagramSkip visual syntax diagram
         .- -d 0-----------.                           
>>-snmp--+-----------------+--findname--mib_variable-----------><
         '- -d debug_level-'                           

Parameters

-d debug_level
Specifies the debug level. The valid debug levels are 0-4. The default level is 0, which means no debug. Each higher trace level includes all the trace messages from the lower levels.
-h target host
Specifies the target host to which you want to send a request. This can be an IPv4 (dotted decimal) or IPv6 (colon hexadecimal) address, a host name, or a winSNMP name in the OSNMP.CONF configuration file. If you do not specify a host, the default is your local host.

Restriction: You cannot specify scope information as part of the host name or the IP address of the target host.

-r retry number
Specifies the maximum number of times to retry the command if it timed out. The default is 2.
-c community_name
Specifies the community name that is used to access the specified variables at the destination SNMP agent. If you do not specify a community name, the default name is public. Community names are not required when using the user-based security model.
Note: Community names are case-sensitive.
-t timeout value
Specifies the amount of time (in seconds) that the snmp command waits for a reply from the SNMP agent. The default value is 3.
-v
Specifies that the output from a request is displayed using verbose output. Use of this option causes the values to be returned with the textual name in place of the MIB object identifier.
-a
Specifies that the request packet is sent using the physical interface addresses, rather than a VIPA address (if one is available) as the originating IP address. By default, the snmp command now uses the VIPA address. Alternately, the NOSVIPA option can be configured in the OSNMP.CONF file.
-m max repetitions
Applies only to getbulk and bulkwalk requests. This is ignored if the function request is not a getbulk or bulkwalk. Maximum repetitions is the number of lexicographic successors to be returned for each variable binding pair after the first -n number successors. For example, starting with successor -n number+1, return -m number of successors for each variable binding pair. The default is 10.
-n nonrepeaters
Applies only to getbulk or bulkwalk requests. This is ignored if the function request is not a getbulk or bulkwalk. The value nonrepeaters is the number of variable binding pairs (name and value), starting with the first, for which only a single successor is returned. The default value is 0.
mib_variable
Specifies the Management Information Base (MIB) object, using its object descriptor (textual name), object identifier in ASN.1 notation, or a combination of the two. When used with walk and bulkwalk requests, this is the MIB object prefix. A prefix can be any leading portion of the complete object identifier. When used with findname, this is the object identifier in ASN.1 notation.
vartype
Specifies the type of value being set. To complete an SNMP SET request, the SMI_type must be known. If no type is specified, snmp searches first the MIBS.DATA file and then the compiled MIB to determine the type. If the variable is not found, an error is returned. If a vartype is specified, the vartype takes precedence over any type that can be assigned in the MIB. The vartype and value must be compatible. For example, if you specify a type of "number" and a value of "foo", an error is returned because "foo" is not a number. The vartype parameter is not case-sensitive. Valid variable types are:
  • bitstring
  • counter
  • counter32
  • counter64
  • display or displaystring
  • integer
  • integer32
  • ipaddress
  • gauge
  • gauge32
  • nsapaddress
  • null
  • objectidentifier or OID
  • octetstring
  • opaque
  • opaqueascii
  • timeticks
  • uinteger
value
Specifies the value to be set by the SET function. If white space is needed in the value, you must enclose the value in double quotation marks ("). If you want to set a variable to a value that is also a type, you must specify the type.
-?
Displays help information.
-p port_number
Specifies the number of the port that listens for traps. If a port number is not specified, the snmp command trap function listens on the well-known port 162, the default port for snmp traps.
SNMP request types:
get
Sends a request to an SNMP agent for a specific management information base (MIB) variable. The snmp command then waits for a response or times out.
getnext
Sends a request to an SNMP agent for the next MIB variable that lexicographically follows the mib_variable value specified. The snmp command then waits for a response or times out.
getbulk
Obtains the value of the variables in the MIB tree specified by the OID or MIB variable name. A single getbulk request performs the same function as a series of getnext requests with fewer data exchanges between the snmp command and the SNMP agent.
set
Sends a request to an SNMP agent to set a specific MIB variable. The snmp command then waits for a response or times out.
walk
Issues a getnext request for a specified prefix, then continues to issue getnext requests for as long as there are variables that match the specified prefix. A prefix can be any leading portion of the complete object identifier.
bulkwalk
Issues a GETBULK request for a specified prefix, then continues to issue GETBULK requests for as long as there are variables that match the specified prefix.
trap
Listens for SNMP traps and displays trap information when they occur. Uses the default well-known port 162 or the port number specified on the -p option. The snmp trap function continues to listen for traps until the process is killed or canceled.
findname
Sends a request that a search be done to obtain the textual name, for a given mib_variable input, whose internal ASN.1 value best matches the input ASN.1 value. The search first checks the MIBS.DATA file, and if a matching textual name is not found, continues with the compiled MIB. Only one mib_variable is allowed per snmp findname invocation.

Usage

Examples