C.2. Common Command-Line Arguments For the most part, the Net-SNMP commands follow a similar command structure; they share many options and use roughly the same syntax. For example, in the abstract, an snmpget command looks like this: snmpget options hostname objectID... In other words, the command name is followed by a series of options, the hostname of the system you want to poll, and one or more object IDs. (Note that if you use SNMPv1 or SNMPv2, you can use the -c community option to specify the community string. You can also provide a default hostname in your snmp.conf file.) The syntax of snmpset is only slightly different; because snmpset changes object values, it requires you to specify the object's datatype and the new value: snmpset options hostname objectID type value... Table C-1 summarizes some of the most useful options common to all Net-SNMP commands. See the snmpcmd(1) manpage for a complete list. Table C-1. Summary of command-line optionsOption | Description |
---|
-m | Specifies which MIB modules you would like the command to load. If you want the command to parse the MIB file for a particular vendor, copy the MIB file to /usr/local/share/snmp/mibs and invoke the command with the option -m ALL. The argument ALL forces the command to read all the MIB files in the directory. Setting the environment variable $MIBS to ALL achieves the same thing. If you don't want the command to read all the MIB files, you can follow the -m option with a colon-separated list of the MIB files you want parsed. | -M | Allows you to specify a colon-separated list of directories to search for MIB files. This option is useful if you don't want to copy MIB files into the default MIB location. Setting the shell variable $MIBDIRS has the same effect. | -IR | Performs a random-access search through the MIB database for an OID label. By default, the commands assume that you specify an object ID relative to .iso.org.dod.internet.mgmt.mib-2. In practice, this option allows you to avoid typing long OIDs for objects that aren't under the mib-2 subtree. For example, there's a group of objects in the Cisco MIB named lcpu. If you use the -IR option, you can retrieve objects in this group without typing the entire OID; the following command is sufficient: snmpget -IR hostname community lcpu.2 | -On | Prints OIDs numerically (e.g., .1.3.6.1.2.1.1.3.0) | -Of | Prints full textual OIDs. | -Os | Prints the entire OID (i.e., starting with .1). | -OS | Displays only the final part of the OID, in symbolic form (e.g., sysUpTime.0). | -v | Specifies which version of SNMP to use: -v1, -v2c, and -v3 for SNMPv1, SNMPv2 and SNMPv3 respectively. | -h | Displays a help message. | -c | Specifies the community string for SNMPv1 or SNMPv2c. |
|