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 community objectID...

In other words, the command name is followed by a series of options, the hostname of the system you want to poll, the community string, and one or more object IDs. (Note that you can use the -c community option instead of placing the community string after the hostname. 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 community objectID type value...

Table C-1 summarizes some of the most useful options that are common to all Net-SNMP commands. See the snmpcmd(1) manpage for a complete list.

Table C-1. Summary of Command-Line Options

Option

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

Get Essential SNMP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.