Monitor Debian Servers with Net-SNMP


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.

 

Terminology

 

  • 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.

 

Information Gathering

 

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.

On Client

 

Log into the client and perform the following as root.

  1. 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
  2. Edit /etc/default/snmpd
    1. comment out the line
      export MIBS=
      (place a pound sign in front of it)
    2. 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'
      1. 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
  3. Make a backup copy of the configuration file
    mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original
  4. Create a minimal configuration file. All you need is the first line, the other two are included as "nice to have"
    1. edit /etc/snmp/snmpd.conf
    2. 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 <contact@example.com> 
      
  5. Edit /etc/snmp/snmp.conf, and comment out the following line (by placing a pound sign in front of it)
    mibs:
  6. 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.
    1. /etc/init.d/snmpd stop
    2. /etc/init.d/snmpd start
    3. /etc/init.d/snmpd status
      1. If the final command above shows (status)
      2. snmpd is running.
      3. snmptrapd is not running ... failed!
      4. we are good. You have successfully installed the snmpd listener

On Server

  1. Log into the server and execute the following command as root
    clear ; /usr/bin/snmpwalk -Oav -v2c -c COMMUNITY_NAME IP_OF_CLIENT
    1. 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.
    2. 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/syslog
      then 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
  2. You can now set up the device in Cacti on the server (assuming you're using it).
Last update:
2014-01-22 08:19
Author:
Rod
Revision:
1.4
Average rating: 1 (1 Vote)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags