Installation and configuration of the SNMP daemon
The Linux machine that you wish to monitor may or may not have the necessary SNMP software installed on it already. If not it will be necessary to deploy the SNMP programs using the appropriate package management tools for this distribution. As a minimum the net-snmp package is required and we would also recommend installing net-snmp-utils for debugging purposes.
Install net-snmp and net-snmp utils
Red Hat Family
The SNMP packages may be installed from the command line using yum:
# yum install net-snmp net-snmp-utils
The SNMP packages may be installed from the command line using zypper:
# zypper install net-snmp net-snmp-utils
The SNMP packages may be installed from the command line using apt:
# apt-get install snmpd
Once the software is installed you need to start the daemon and set it to autostart:
# chkconfig --level 2345 snmpd on
# service snmpd start
To test the service started perform an snmpwalk from the command line to query the daemon and report back the results, using -v 1 for SNMP version 1, -c reads the configuration file, public the community read setting, localhost the device to be queried.
$ snmpwalk -v 1 -c public localhost
On most systems you will probably see a listing of a handful of system variables like system name, etc., which is probably less than you might expect and certainly not enough to do any monitoring. There are a couple of reasons for this and changing this requires editing of the config file. Fire up your favourite editor and point it at /etc/snmp/snmpd.conf.
The following examples use the default vi text editor. Information on vi (visual editor) is available in the SS64 quick reference guide
# vi /etc/snmp/snmpd.conf
Within snmpd.conf there should be a line that looks like:
view systemview included .188.8.131.52.2.1.1
This permits access to the subtree .184.108.40.206.2.1.1, which contains the system information objects, such as description, name, etc. There are a number of additional subtrees that provide useful information - as a starting point we would recommend adding the following lines to the configuration file:
view systemview included .220.127.116.11.18.104.22.168.1
view systemview included .22.214.171.124.4.1
Adding these will make visible uptime and system performance information respectively.
After applying the changes then saving the file, re-start the SNMP daemon to load the updated settings and perform an snmpwalk to ensure the expected information is displayed.
# service snmpd restart
Stopping snmpd: [ OK ]
Starting snmpd: [ OK ]
# snmpwalk -v 1 -c public localhost
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-308.11.1.el5.centos.plus #1 SMP Tue Jul 10 16:44:19 EDT 2012 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10...
Where running an external firewall and/or iptables on the machine itself, you will have to configure it or them to allow access to port 161 via UDP. You can restrict the source addresses from which access will be allowed if you wish to do so as a security measure. You can also change the default community string (public in the example above) in the snmpd.conf file if you want to avoid use of this default value. Although it gives read-only access, changing it will prevent access using this well-known password.
Please note that we are not responsible for the content of external sites.