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 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 option with a colon-separated list of the MIB files you ...

Get Essential SNMP, 2nd Edition 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.