SNMP (or Simple Network Management Protocol) is used to gather data on what is going on within a device, such as load, hard disk states, bandwidth. These data are used by network monitoring tools such as Cacti to generate graphs for monitoring purposes.
In a typical deployment of Cacti and SNMP, there will be one or more SNMP-enabled devices, and a separate monitoring server where Cacti collects SNMP feeds from those devices. Please keep in mind that all the devices that need to be monitored must be SNMP enabled. In this tutorial, we will be configuring Cacti and SNMP on the same Linux server for demonstration purpose.
Configure SNMP on Debian or Ubuntu
To install SNMP agent (snmpd) on a Debian-based system, run the following command.
Then edit its configuration like the following.
# this will make snmpd listen on all interfaces agentAddress udp:161 # a read only community 'myCommunity' and the source network is defined rocommunity myCommunity 172.17.1.0/24 sysLocation Earth sysContact firstname.lastname@example.org
After editing the config file, restart snmpd.
Configure SNMP on CentOS or RHEL
To install SNMP tools and libraries, run the following command.
Then edit an SNMP config file like the following.
# A user 'myUser' is being defined with the community string 'myCommunity' and source network 172.17.1.0/24 com2sec myUser 172.17.1.0/24 myCommunity # myUser is added into the group 'myGroup' and the permission of the group is defined group myGroup v1 myUser group myGroup v2c myUser view all included .1 access myGroup "" any noauth exact all all none
root@server:~# chkconfig snmpd on
Restart snmpd service, and add it to startup service list.
SNMP can be tested by running the snmpwalk command. If SNMP has been successfully configured, this command will generate a ton of output.
iso.126.96.36.199.188.8.131.52 = STRING: "Linux mrtg 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64" iso.184.108.40.206.220.127.116.11 = OID: iso.18.104.22.168.1.8072.3.2.10 iso.22.214.171.124.126.96.36.199 = Timeticks: (2097) 0:00:20.97 ~~ OUTPUT TRUNCATED ~~ iso.188.8.131.52.184.108.40.206.2.0 = Gauge32: 1440 iso.220.127.116.11.18.104.22.168.1.0 = Counter32: 1 iso.22.214.171.124.126.96.36.199.2.0 = Counter32: 0 iso.188.8.131.52.184.108.40.206.220.127.116.11.100.101.102.97.18.104.22.168 = Timeticks: (1) 0:00:00.01 iso.22.214.171.124.126.96.36.199.188.8.131.52.100.101.102.97.184.108.40.206 = Hex-STRING: 07 DD 0B 12 00 39 27 00 2B 06 00
Configure Cacti with SNMP
In this tutorial, we are setting up both Cacti and SNMP on the same Linux server. So go ahead and install Cacti on your Linux server on which SNMP was just configured.
After installation, Cacti web interface can be accessed using the link "http://172.17.1.44/cacti", of course, in your case, the IP address of your server.
The paths during Cacti installation are usually correct. But they can be double checked if necessary.
During the first-time installation, the default username and password for Cacti are "admin" and "admin". You will be forced to change the password after first login.
Add and Manage Devices to Cacti
Cacti will poll devices based on SNMP string that was configured earlier. In this tutorial, we will add only the local server where SNMP is already enabled.
To add devices, we login as admin and go to console in the Cacti admin panel. We click Console > Devices.
There may already be a device named 'localhost'. We do not need it as we will create fresh graphs. We can delete this device from the list. We add a new device by using the 'add' button.
Next, we set the device parameters.
Now that the device has been added, we specify the graph templates that we want to create. This section can be found in the bottom section of the page.
And then we proceed to creating the graphs.
Here, we create graphs for load average, RAM and hard disk, processor.
Interface Graphs and 64-bit Counters
By default, Cacti uses 32-bit counters in SNMP queries. 32-bit counters are sufficient for most bandwidth graphs, but they do not work correctly for graphs greater than 100 Mbps. If it is known that the bandwidth will exceed more than 100 Mbps, it is always advisable to use 64-bit counters. Using 64-bit counters is not hard at all.
Note: It takes around 15 minutes for Cacti to populate new graphs. There are not alternatives to being patient.
Creating Graph Trees
These snapshots illustrate how to create graph trees and how to add graph to those trees.
We can verify the graph in the graph tree.
Finally, we create a user with view permission to only the graph that we have created. Cacti has built in user management system, and it is highly customizable.
After completing these steps, we can log in with the user 'user1' and verify that only this user is able to view the graph.
And thus we have deployed a Cacti server in the network monitoring system. Cacti servers are stable, and can deal with tons of graphs without any problems.
Hope this helps.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.