net-snmp (http://www.net-snmp.org/) allows you to monitor the health of many devices. This document describes how to set up a Debian based server to be monitored by a remote collection point. In our case, we use cacti (http://www.cacti.net/) to make pretty graphs which we then use to monitor the health of our server. This document does not cover the cacti configuration, however.
Both Cacti and Net-SNMP are available as packages under Debian, but neither has a trivial configuration. Setting up snmpd on a Debian server is not trivial, espeically since the default installation for Debian assumes snmp version 3 (snmpV3) which is very security concious. Since our monitoring is done on a secured LAN, I will describe setting up SNMPv2 which is simpler. Do Not use this setup on a network exposed to a public IP, however; SNMPv2 is very insecure.
- In this document, client will refer to the machine being monitored and server will refer to the machine monitoring it.
- snmpd (note the "d" on the end) is the daemon that runs on the client machine. When the server contacts the client, it uses various other programs (like snmpwalk) to request information from the daemon (snmpd) running on the client. As such, we will be working with snmpd configuration files on the client machine.
Prior to doing anything, gather the information you will need.
- Determine the IP of your client. You will need this throughout the process. Use it when you see the tag IP_OF_CLIENT
- Determine the community name of your snmp network. You can, of course, use the default 'public' but it is easier if you use the one set up on the server. The community name is shown in this document as COMMUNITY_NAME.
- You can also include a contact e-mail address and location.
Log into the client and perform the following as root.
- Install the snmpd daemon and the snmp MIBS downloader (MIBS are descriptors and scripts which gather information on a device and format the gathered information for transmittal to the server)
apt-get update && apt-get install snmpd snmp-mibs-downloader
- Edit /etc/default/snmpd
- comment out the line
export MIBS=(place a pound sign in front of it)
- change the line
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'by adding the IP address of the client.
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid IP_OF_CLIENT'
- This will make the snmp accessible only through its private IP address, in case you have a public IP address on the client machine also
- Make a backup copy of the configuration file
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original
- Create a minimal configuration file. All you need is the first line, the other two are included as "nice to have"
- edit /etc/snmp/snmpd.conf
- It should be a blank file, enter the following replacing the italicized text with the correct values
rocommunity the_community_name syslocation Physical Location sysContact ContactName <email@example.com>
- Edit /etc/snmp/snmp.conf, and comment out the following line (by placing a pound sign in front of it)
- Start the snmpd daemon. I usually perform the following three commands on a single line by themselves to give snmpd a chance to shut down. NOTE: you can say
/etc/init.d/snmpd restart, but I prefer to see the thing is actually down before bringing it back up.
- /etc/init.d/snmpd stop
- /etc/init.d/snmpd start
- /etc/init.d/snmpd status
- If the final command above shows (status)
- snmpd is running.
- snmptrapd is not running ... failed!
- we are good. You have successfully installed the snmpd listener
- Log into the server and execute the following command as root
clear ; /usr/bin/snmpwalk -Oav -v2c -c COMMUNITY_NAME IP_OF_CLIENT
- If you get pages of output, snmpd is correctly set up on server. I generally get over 1700 lines of output on a Linux server.
- If you get no output, or if the output is more limited, open a separate window to the client and, as root, type
tail -f /var/log/syslogthen run the snmpwalk command again. You should see syslog spewing a lot of messages explaining what the errors were. I don't say they are useful or understandable, but they are messages
- You can now set up the device in Cacti on the server (assuming you're using it).