|Skip Navigation Links|
|Exit Print View|
|man pages section 1M: System Administration Commands Oracle Solaris 10 1/13 Information Library|
- commands to communicate with a network entity using SNMP requests
snmpcmd [options] agent [parameters]
This manual page describes the common options for the following SNMP commands:
The command line applications use the SNMP protocol to communicate with an SNMP-capable network entity, an agent. Individual applications usually (but not invariably) take additional parameters that are given after the agent specification. These parameters are documented in the manual pages for each application.
The following options are supported:
Set the authentication protocol (MD5|SHA) used for authenticated SNMPv3 messages. Overrides the defAuthType token in the snmp.conf file.
Set the authentication pass phrase used for authenticated SNMPv3 messages. Overrides the defAuthPassphrase token in the snmp.conf file. Insecure to specify pass word phrases on the command line, see snmp.conf(4).
Set the community string for SNMPv1/v2c transactions. Overrides the defcommunity token in the snmp.conf file.
Dump (in hexadecimal) the sent and received SNMP packets.
Turn on debugging output for the given token(s). Try ALL for extremely verbose output.
Set the authoritative (security) engineID used for SNMPv3 REQUEST messages. This is the engineID of the agent or proxy (for example, 800000020109840301). This value will be discovered if not supplied.
Set the context engineID used for SNMPv3 REQUEST messages scopedPdu. This is the engineID of the agent (for example, 800000020109840301). This will be the authoritative engineID if not specified.
Display a brief usage message and then exit.
Display a list of configuration file directives understood by the command and then exit.
Specifies input parsing options. See INPUT OPTIONS below.
Set the securityLevel used for SNMPv3 messages (noAuthNoPriv|authNoPriv|authPriv). Appropriate pass phrase(s) must be provided when using any level higher than noAuthNoPriv. Overrides the defSecurityLevel token in the snmp.conf file.
Specifies a colon-separated list of MIB modules to load for this application. This overrides the environment variable MIBS.
The special keyword ALL is used to specify all modules in all directories when searching for MIB files. Every file whose name does not begin with a period (.) will be parsed as if it were a MIB file.
If the miblist has a leading plus sign (+), then the listed MIB modules are loaded in addition to MIB modules specified in the environment variable MIBS.
If a mibfile token is specified in the snmp.conf file, the -m MIB option overrides the mibfile token.
Specifies a colon-separated list of directories to search for MIBs. This overrides the environment variable MIBDIRS.
If dirlist has a leading plus sign (+), then the given directories are added to the list of MIB directories. Without the leading +, the given directory list overrides the list specified with the environment variable MIBDIRS. Note that the directories listed at the end of the list have precedence over directories at the beginning of the list.
If no value is specified for the environment variable MIBDIRS, then the command will still search a default mib directory, after it searches the MIB directories specified on the -M option. The default directory is /etc/sma/snmp/mibs. To avoid having a default mib directory searched, set the MIBDIRS environment variable to the empty string (""). Even if the default MIB directory is searched, the directories specified in the -M option have precedence in the search order over the default directory.
If the -M option is specified and either a mibfile or mibdirs token is also specified in the snmp.conf file, the directories in the -M option have precedence in the MIB search order, over the directories set with either the mibdirs token and the mibfile token.
Set the destination contextName used for SNMPv3 messages. The default contextName is the empty string (""). Overrides the defContext token in the snmp.conf file.
Specifies output printing options. See OUTPUT OPTIONS below.
Specifies MIB parsing options. See MIB PARSING OPTIONS below.
Specifies the number of retries to be used in the requests. The default is 5.
Specifies the timeout in seconds between retries. The default is 1.
Set the securityName used for authenticated SNMPv3 messages. Overrides the defSecurityName token in the snmp.conf file.
Specifies the protocol version to use: 1 (RFCs 1155-1157), 2c (RFCs 1901-1908), or 3 (RFCs 2571-2574). The default is version 1. This option overrides the defVersion token in the snmp.conf file.
Display version information for the application and then exit.
Set the privacy protocol (DES) used for encrypted SNMPv3 messages.
Set the privacy pass phrase used for encrypted SNMPv3 messages. Overrides the defPrivPassphrase token in the snmp.conf file. Note that it is insecure to specify password phrases on the command line. See snmp.conf(4).
Set the engineBoots and engineTime used for authenticated SNMPv3 messages. This will initialize the local notion of the agents boots/time with an authenticated value stored in the LCD. This value will be discovered if not supplied.
The string agent specifies the remote SNMP entity with which to communicate. The format of this parameter is defined in the AGENT SPECIFICATION section below.
The agent specification (see SYNOPSIS) takes the form:
At its simplest, the agent specification consists of a hostname or an IPv4 address in the standard, "dotted quad" notation. In this case, communication will be attempted using UDP/IPv4 to port 161 of the given host. Otherwise, the transport-address part of the specification is parsed according to the following table:
<transport-specifier> <transport-address> format udp hostname[:port]
Note that transport-specifier strings are case-insensitive so that, for example, "tcp" and "TCP" are equivalent. Here are some examples, along with interpretations:
Perform query using UDP/IPv4 datagrams sent to myhost on port 161. The :161 is redundant here because that is the default SNMP port.
Identical to the previous specification. The udp: is redundant here because UDP/IPv4 is the default transport.
The Net-SNMP MIB parser mostly adheres to the Structure of Management Information (SMI). As that specification has changed through time, and in recognition of the diversity in compliance expressed in MIB files, additional options provide more flexibility in reading MIB files.
Show some warning messages in resolving the MIB files. Can be also set with the configuration token mibWarningLevel.
Show additional warning messages. Can be also set with the configuration token mibWarningLevel.
Show MIB errors. Can be also set with the configuration token showMibErrors. An example of an error that would be shown is if an imported module is not found during MIB parsing.
Allow ASN.1 comment to extend to the end of the MIB source line (that is, disallow the use of two dashes (--) to terminate comments). This overcomes some problems with manually maintained MIB files. Can be also set with the configuration token strictCommentTerm.
Toggles the default of whether or not to save the DESCRIPTIONs of the MIB objects when parsing. Since the default is to save the DESCRIPTIONs, specifying -Pd causes the DESCRIPTIONs not to be saved during MIB parsing. For example:
snmptranslate -Td -OS -IR system.sysDescr.0
will show a description, while:
snmptranslate -Td -OS -IR -Pd system.sysDescr.0
will not show a description. Collecting the DESCRIPTION information into the parsed hierarchy increases the memory used by the size of each DESCRIPTION clause.
Allow underline characters in symbols. Can be also set with the configuration token mibAllowUnderline.
Replace MIB objects using the last read MIB file. The parser replaces MIB objects in its hierarchy whenever it sees a subidentifier and name match.
Caution - Setting this option might result in an incorrect hierarchy. Can be also set with the configuration token mibReplaceWithLatest.
Output display can be controlled by passing various parameters to the -O flag. The following examples demonstrate this feature.
The default output displays as follows:
snmpget -c public -v 1 localhost system.sysUpTime.0 SNMPv2-MIB::sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
Removes the equal sign and type information:
Removes the type information:
system.sysUpTime.0 = 1:15:09:27.63
Gives you the complete OID:
.iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.0 = \ Timeticks: (14096763) 1 day, 15:09:27.63
Deletes all but the last symbolic part of the OID:
sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
A variation on -Os that adds the name of the MIB that defined the object:
SNMPv2-MIB::sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
Starting with release 5.0, this is the default output format.
Displays the OID in the UCD-style (inherited from the original CMU code). That means removing a series of "standard" prefixes, if relevant, and breaking down the OID into the displayable pieces. For example, the OID vacmSecruityModel.0.3.119.101.115 is broken down by default and the string hidden in the OID is shown. The result would be: vacmSecurityModel.0."test". The -Ob option disables this feature.
system.sysUpTime.0 = Timeticks: (14096763) 1 day, 15:09:27.63
Displays the OID numerically:
.22.214.171.124.126.96.36.199.0 = Timeticks: (14096763) 1 day, 15:09:27.63
Removes the symbolic labels from enumerations:
snmpget -c public -v 1 localhost ip.ipForwarding.0 ip.ipForwarding.0 = INTEGER: forwarding(1) snmpget -c public -v 1 -Oe localhost ip.ipForwarding.0 ip.ipForwarding.0 = INTEGER: 1
When OIDs contain a index to a table, they are broken into the displayable pieces and shown to you. For example, the OID vacmSecurityModel.0.3.119.101.115 is nicely broken down by default and the string hidden in the OID is shown to you as vacmSecurityModel.0."wes". The -Ob option disables this feature and displays it as vacmSecurityModel.0.3.119.101.115 once again.
Modifies the index strings to include a backslash (\) to escape the quotes, to allow them to be reused in shell commands, such as vacmSecurityModel.0.\"wes\"
Modifies the output of index OIDs to look more "program-like". Square brackets are placed around each index and the DISPLAY-HINT information and string conversions are used to format each index. If you take an entry from the IPV6-MIB::ipv6RouteTable, it is indexed with an IPv6 address and two integers, and if you are used to IPv6 addresses you know that decimal OIDs are not the preferred notation. Compare:
snmpgetnext -OS host IPV6-MIB:ipv6RouteTable IPV6-MIB::ipv6RouteIfIndex.188.8.131.52.255.0.0.0.0.0.0.0.0.0.0.0.64.1 \ = INTEGER: 2 snmpgetnext -OSX host IPV6-MIB:ipv6RouteTable IPV6-MIB::ipv6RouteIfIndex[3ffe:100:ff00:0:0:0:0:0] = INTEGER: 2
If a string-valued object definition does not include a display hint, then the library attempts to determine whether it is an ASCII or binary string, and displays the value accordingly. This flag bypasses this check, and displays all strings as ASCII. Note that this does not affect objects that do have a display hint.
This works similarly to -Oa, but displays strings as hexadecimal values.
If hexadecimal code is displayed, this will also display any printable characters after the hexadecimal codes.
Output only the variable value, not the OID:
snmpget -c public -v 1 -Ov localhost ip.ipForwarding.0 INTEGER: forwarding(1)
Do not display the UNITS suffix at the end of the value.
Output timeticks values as raw numbers:
system.sysUpTime.0 = 14096763
Note that most of these options can be turned on or off by default by tuning the snmp.conf file. See snmp.conf(4) for details.
The -I flag specifies various options that control how your input to the program is parsed. By default, unless one of the following flags is specified, all input parsing methods are used: First the OID is parsed in the normal way, then -IR is used, then -Ib is used. The use of one of the following flags forces a command to use only one method.
Specifies random access lookup, so that if the entire OID path is not specified, it will search for a node in the MIB tree with the given name. Normally, you'd have to specify the vacmSecurityModel OID above as:
.iso.org.dod.internet.snmpV2.snmpModules.snmpVacmMIB.vacmMIBObjects. \ vacmSecurityToGroupTable.vacmSecurityToGroupEntry.vacmSecurityModel.0.\ "wes"
But the use of the -IR flag allows you to shorten that to vacmSecurityModel.0."wes". This OID needs to be quoted to prevent the shell from swallowing the double quotes: But the use of the -IR flag allows you to shorten that to just vacmSecurityModel.0."wes". This OID must be quoted to prevent the shell from swallowing the double quotes: 'vacmSecurityModel.0."wes"'.
For more information, see the RANDOM ACCESS MIBS section, below.
Indicates that the expression you gave the command is a regular expression that should be used to search for the best match possible in the MIB tree. This would allow you to specify the vacmSecurityModel MIB node as something as generic as vacmsecuritymodel (since case-insensitive searches are done) or vacm.\(**model. Note that multiple matches are obviously possible (.\(** matches everything). The best result is calculated as the one that matches the closest to the beginning of the node name and the highest in the tree. A side effect of this option is that you cannot specify indexes or multiple nodes, because the period (.) is treated as part of the regular expression.
Use the traditional UCD-style input approach of assuming that OIDs are rooted at the mib-2 point in the tree (unless they start with an explicit period (.)) If random access lookup is in effect (which is the default for most commands), then this will affect only OIDs specified with a leading numeric subidentifier (and no initial period). Thus an input of snmpcmd ... 1 would refer to iso (from v5.0 onwards) while snmpcmd -Iu ... 1 would refer to system.
By default, indices into tables and values to be assigned to objects are checked against the range and type specified in the MIB. The -Ir flag disables this check. This flag is mostly useful when you are testing an agent. For normal operation, it is useful to get your requests checked before they are sent to the remote agent. The diagnostic that the library can provide is also much more precise.
By default, the library will use DISPLAY-HINT information when assigning values. This flag disables this behavior. The result is that, instead of:
snmpset localhost HOST-RESOURCES-MIB::hrSystemDate.0 = \ 2002-12-10,2:4:6.8
you will have to write:
snmpset localhost HOST-RESOURCES-MIB::hrSystemData.0 x \ "07 D2 0C 0A 02 04 06 08"
In previous releases of the UCD-SNMP package (and if using the -Iu option), an object identifier such as system.sysDescr.0 is looked up in a single "well known" place, built into the SNMP library (or specified by the P@REFIX environment variable). The standard place is .iso.org.dod.internet.mgmt.mib-2. The identifier can alternatively be a complete object identifier. This is designated by a leading "dot" if using UCD-input style, and is the first thing tried otherwise. To simplify the specification of object identifiers the library supports random access to the identifiers in the MIBs. This is requested by the -IR option to the SNMP applications. Additionally, -Os prints OIDs in this manner. Using this, system.sysDescr.0 can also be entered as sysDescr.0.
To search only a single MIB for the identifier (if it appears in more than one), specify it as SNMPv2-MIB::sysDescr.0. Use -OS to print output OIDs in this manner; this is the default since v5.0. This notation also ensures that the specified MIB is loaded, that is, it need not be mentioned in the -m option (or MIBS environment variable).
The standard prefix for object identifiers (if using UCD-style output). Defaults to .iso.org.dod.internet.mgmt.mib-2.
The list of MIBs to load. Defaults to:
Overridden by the -m option.
The list of directories to search for MIBs. Defaults to /etc/sma/snmp/mibs. Overridden by the -m option.
Agent configuration file. See snmpd.conf(4).
Application configuration files. See snmp.conf(4).
See attributes(5) for descriptions of the following attributes:
snmpbulkwalk(1M), snmpbulkwalk(1M), snmpdf(1M), snmpget(1M), snmpgetnext(1M), snmpnetstat(1M), snmpset(1M), snmptrap(1M), snmpusm(1M), snmpvacm(1M), snmpwalk(1M), snmp.conf(4), snmpd.conf(4), attributes(5)