UNIX System Administration Handbook - Evi Nemeth [382]
As in other implementations, the agent collects information about the local host and serves it to SNMP managers across the network. The default installation includes MIBs for network interface, memory, disk, process, and CPU statistics. The agent is easily extensible since it can execute an arbitrary UNIX command and return the command’s output as an SNMP response. You can use this feature to monitor almost anything on your system with SNMP.
By default, the agent is installed as /usr/sbin/snmpd. It is usually started at boot time and reads its configuration information from files in the /etc/snmp directory. The most important of these files is snmpd.conf, which contains most of the configuration information and comes shipped with a bunch of sample data collection methods enabled. Although the intention of the UCD authors seems to have been for users to edit only the snmpd.local.conf file, you must edit the snmpd.conf file at least once to disable any default data collection methods that you do not plan to use.
The UCD SNMP configure script lets you specify a default log file and a couple of other local settings. You can use snmpd -l to specify an alternate log file or -s to direct log messages to syslog. Table 20.3 shows a list of snmpd’s most important flags. We recommend that you always use the -a flag. For debugging, you should use the -V, -d, or -D flags, each of which gives progressively more information.
Table 20.3 Useful flags for UCD’s snmpd
It’s worth mentioning that many useful SNMP-related Perl modules are available. Look on CPAN7
for the latest information if you are interested in writing your own network management scripts.
20.9 NETWORK MANAGEMENT APPLICATIONS
We begin this section by exploring the simplest SNMP management tools: the commands provided with the UCD SNMP package. These commands are useful for familiarizing yourself with SNMP, and they’re also great for one-off checks of specific OIDs. Next, we look at MRTG, a program that generates historical graphs of SNMP values, and NOCOL, an event-based monitoring system. We conclude with some recommendations of what to look for when purchasing a commercial system.
The UCD SNMP tools
Even if your system comes with its own SNMP server, you may still want to compile and install the seven client-side tools, listed in Table 20.4, from the UC Davis package.
Table 20.4 Command-line tools in the UCD SNMP package
In addition to their value on the command line, these programs are tremendously handy in simple scripts. It is often helpful to have snmpget save interesting data values to a text file every few minutes. (Use cron to implement the scheduling; see Chapter 9, Periodic Processes.)
snmpwalk is another useful tool. Starting at a specified OID (or at the beginning of the MIB, by default), this command repeatedly makes “get next” calls to an agent. This behavior results in a complete list of available OIDs and their associated values. Here’s a sample snmpwalk of the host jaguar (“public” is the community string):
% snmpwalk jaguar public
system.sysDescr.0 = Linux jaguar 2.2.12-20 #1 Mon Sep 27 10:40:35 EDT 1999
system.sysUpTime.0 = Timeticks: (88516617) 10 days, 5:52:46.17
system.sysName.0 = jaguar
system.sysLocation.0 = Second Floor Machine Room
interfaces.ifNumber.0 = 2
interfaces.ifTable.ifEntry.ifIndex.1 = 1
interfaces.ifTable.ifEntry.ifIndex.2 = 2
interfaces.ifTable.ifEntry.ifDescr.1 = "lo0" Hex: 6C 6F 30
interfaces.ifTable.ifEntry.ifDescr.2 = "eth0" Hex: 65 74 68 30
interfaces.ifTable.ifEntry.ifType.1 = softwareLoopback(24)
interfaces.ifTable.ifEntry.ifType.2 = ethernet-csmacd(6)
interfaces.ifTable.ifEntry.ifMtu.1 = 3924
interfaces.ifTable.ifEntry.ifMtu.2 = 1500
interfaces.ifTable.ifEntry.ifInOctets.1 = 12590602
interfaces.ifTable.ifEntry.ifInOctets.2 = 2287718531
interfaces.ifTable.ifEntry.ifInUcastPkts.1 = 75576
interfaces.ifTable.ifEntry.ifInUcastPkts.2