How to Install and Configure Net SNMP in Linux

Cacti and other Network monitoring tools requires SNMP (Simple Network Management Protocol) to monitor your server's network bandwidth, cpu loads, total ammounts of RAM and Hard Drive etc. To monitor your Linux server, you must have net-snmp installed.

Installing Net-SNMP on Debian or Ubuntu

For Debian, Ubuntu and other Debian-based distro, type this command:

apt-get install snmpd

Edit the /etc/default/snmpd file

vi /etc/default/snmpd

find this line

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

and remove the 127.0.0.1, thus

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'

We remove the 127.0.0.1 to allow snmp to listen on all interfaces.

Install Net-SNMP on Red Hat, CentOS and Fedora

To install net-snmp on Red Hat, CentOS and Fedora, type this command:

yum install net-snmp net-snmp-utils

Make sure your net-snmp always starts during startup

chkconfig snmpd on

and start your net-snmp

service snmpd start

Configure Net-SNMP

Now edit your /etc/snmp/snmpd.conf

vi /etc/snmp/snmpd.conf

and add this line to the end of the file

rocommunity public

This will enable SNMP version 1/2 read-only requests from any host, with the community name public.
With this minimal configuration, you'll be able to graph CPU usage, load average, network interfaces, memory / swap usage, logged in users and number of processes.

You can also restrict from which hosts from your network

rocommunity public 192.168.0.1

or entire network SNMP queries are allowed.

rocommunity public 192.168.0.0/24

Restart your net-snmp and check its configurations:

/etc/init.d/snmpd restart
snmpwalk -v 2c -c public 192.168.0.1 system

Should return this output:

SNMPv2-MIB::sysDescr.0 = STRING: Linux ubuntu01 2.6.24-20-generic #1 SMP Mon Jul 28 13:49:52 UTC 2008 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (175589) 0:29:15.89
SNMPv2-MIB::sysContact.0 = STRING: Root  (configure /etc/snmp/snmpd.local.conf)
SNMPv2-MIB::sysName.0 = STRING: ubuntu01
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (configure /etc/snmp/snmpd.local.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00

Open your Cacti and add this device.