Open Source Software Technical Articles

Want the Best of the Wazi Blogs Delivered Directly to your Inbox?

Subscribe to Wazi by Email

Your email:

Connect with Us!

Current Articles | RSS Feed RSS Feed

Cacti Makes Device Monitoring Simple


Every organization must monitor its infrastructure's uptime and performance. While the popular Nagios application is a good general-purpose monitoring program that you can extend with plugins to handle just about any task, you may do even better by employing Cacti as a graphical front end to RRDTool's data logging and graphing functionality. Cacti was developed specifically to monitor and collect performance information, while Nagios is more oriented toward state changes, such as noting whether a daemon is up or down.

RRDTool stores all of the necessary information to create graphs and populate them with data in a MySQL database. Cacti provides templates to gather and show information such as system load (CPU, RAM, disks), users connected, MySQL load, and Apache load, all of which can affect the performance of your site.

Cacti's front end is completely PHP-driven. It supports data gathering via different methods such as scripts in any language and SNMP. It also maintains graphs, data sources, and round robin archives in a MySQL database.


To see how Cacti and RRDTool can help monitor devices on a network, we'll use CentOS 6 as our server platform. To run properly, Cacti need a complete LAMP stack and RRDTool installed. Apache, PHP, and MySQL are available in the standard CentOS repository, while RRDTool is available in EPEL (Extra Packages for Enterprise Linux), a repository that holds useful packages for Red Hat Enterprise Linux-based distributions, including CentOS. If you don't already have EPEL among your sources you can add it easily. If you are unsure about whether you have EPEL installed, run the command # rpm -qa |grep -i epel. If the output is a blank line, you probably don't have it.

The command to add EPEL differs depending on your server's CPU hardware architecture. To install it on a 32-bit system, run:

# rpm -ivh

If you have a 64-bit system, run:

# rpm -ivh

Then update the system with the command # yum update. Now you can use yum as root to install all of the necessary packages:

# yum -y install httpd
# chkconfig httpd on
# service httpd start

# yum -y install php php-mysql php-snmp php-xml

# yum install mysql mysql-server
# chkconfig mysqld on
# service mysqld start

# yum install -y rrdtool-php rrdtool

# yum install -y cacti net-snmp

The Cacti installation procedure adds a configuration file for Apache – namely /etc/httpd/conf.d/cacti.conf – so you have to restart Apache with the command:

# service httpd restart

Before you can use Cacti you must configure a MySQL database for it. Create the database with the command:

# mysqladmin --user=root create cacti

Import the default Cacti database from the projects doc directory:

# mysql cacti < /usr/share/doc/cacti-0.8.7i/cacti.sql

Though it's optional, you should also create a MySQL username and password for Cacti. Here and below I've specified the username cactiuser, but you can use any name you like:

# mysql --user=root mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

Now edit /usr/share/cacti/include/config.php and specify the database type, name, host, user, and password for your Cacti configuration.

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";

Next, set the appropriate permissions on Cacti's directories for graph and log generation. Execute this command from inside Cacti's directory to change the permissions:

# chown -R cactiuser rra/ log/

To have Cacti start gathering data, add a line to your /etc/crontab file similar to:

*/5 * * * * cactiuser php /usr/share/cacti/poller.php > /dev/null 2>&1

The Cacti application collects its data using a utility known as a poller. This line tells cron to use the standard poller and gather data every five minutes.


Now you can point your web browser to http://your-server/cacti/ to invoke a wizard that asks you if this is a new installation, and that verifies that all the variables and settings used by Cacti are correct (see figure below). Once it finishes successfully you can log into Cacti with a username and password of admin. You will be required to change this password immediately.

[caption id="attachment_177762" align="alignnone" width="205" caption="Cacti installation checklist"][/caption]

Note that during the installation you'll be asked which versions of some packages are you using. To determine which versions of RRDTool and net-snmp are installed on your system, use the commands:

# rpm –qa net-snmp
# rpm –qa rrdtool

Cacti Configuration

Now you can work from the web interface to check graphs and add new devices to the Cacti installation. In Cacti, a device can be any hardware or software that can be monitored remotely or locally. Your local machine should already be listed, though when you first invoke Cacti no graphs may be ready, so wait a few minutes and check the graphs again. You should see information about your local machine, such as CPU usage and network traffic.

To add a network device, you have to know its IP address and SNMP credentials. In particular, for devices that use SNMPv2, you have to give the SNMP community. With the improved security in SNMPv3 you have to give more information.

Cacti has a set of data templates that define the structure for storing objects' data, and that recognize the most common hardware; in practice, they use the MIB of the hardware. This kind of template is applied to specific hosts to create RRD files.

To add a new device follow these steps:

    • Choose Add a device, and specify the name of the device, its IP address, and the SNMP information.

    • After saving your new device, you should be redirected back to the same edit form with some additional information. If the SNMP connection is successful you will see in the new device screen the SNMP information in the top left.

    • By default Cacti should have added the device's SNMP Interface Statistics to the Associated Data Query. You can also verify the status of the SNMP Interface Statistics Data Query. It should say "Success" and show the number of items and rows. You can also click on Verbose Query to get raw SNMP data.

Cacti also uses graph templates, which are applied to specific hosts to create raw RRDTool graph statement. If you want to create a graph for a device, click on Create Graphs for this Host. Near the top of the screen, select the Graph Templates that represent basic information of the device that you are adding, and the interfaces you want to graph (see figure below). Select the appropriate Graph Type; if you have 10/100 interfaces, I suggest using In/Out bits with 95th Percentile, while for Gigabit Ethernet interfaces you can use In/Out bits (64-bit counters). You can't graph VLAN interfaces, however, because they don't report statistics properly. When you've chosen the settings you like, click Create.

[caption id="attachment_177765" align="alignnone" width="300" caption="Graph information selection screen"][/caption]

After some time, once Cacti has collected enough data, you'll see graphs similar to these:

You can in Cacti add all your network devices that have an SNMP daemon active, then create different graphs for each network device.

When you add a device you can optionally choose a host template for it. Host templates serve a different purpose than data and graph templates. Instead of abstracting the fields of a host, a host template allows you to associate graph templates and data queries with a given host type. In other words, a host template is a predefined set of graphs and/or data queries that can be assigned to devices. Using a host template for complex devices reduces the administrative task for adding devices; you can define an appropriate template once and assign it multiple times.

Best Practice

I hope you can see how simple Cacti makes it to get information on your network devices. It uses SNMP to get and store over time all the information on your network devices and their adapters. I use Cacti both to analyze data in real time, and more frequently to see the usage history of a particular network adapter. RRD can store information for a long time, so you can easily see if something in changing in your network.

While the network is Cacti's usual target, you can also use Cacti to get information about Windows and Linux hosts. Just enable the SNMP protocol on any hosts you want to track and write your own host template, or download one from the project's contribute page.

Cacti also has some plugins that extend the use of this software. I suggest trying Mactrack, which scans network devices and locates and automatically associates MAC addresses with their specific IP addresses. It also collects and stores network interface information, such as bandwidth utilization error counters, on all network switches.

Finally, if you want to get fancy, you can integrate Cacti with Nagios. For instance, you could use Cacti to store the performance information of all your network and host devices and use Nagios to check thresholds and send out notifications. In fact, the NPC plugin provides a complete web-based user interface replacement to Nagios while fully integrating into Cacti using the Cacti Plugin Architecture. It makes a great single point of access for trending and alert monitoring.

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.

This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.


ralph polo outlet, michael kors outlet, louis vuitton online, juicy couture outlet, jordan 3, Ralph lauren Polo, iphone cases for 5S, louis vuitton online outlet, ralph lauren outlet, toms online, air jordan shoes, Tiffany co Bracelets, north face outlet, wholesale nfl, north face outlet, louis vuitton online store, ralph lauren outlet, ralph lauren polo outlet, toms outlet store, new york, Ralph lauren men, north face outlet, ralph lauren coupon, cheap nfl jersey, cheap toms, north face outlet, louis vuitton outlet online, louis vuitton outlet, toms on sale, wholesale jerseys nfl, ralph lauren outlets, north face outlet, ralph lauren clothes, toms outlet online, polo shirts for women, iphone cases for 5, abercrombie outlet, Hollister Online Shop, jordan 11, ralph lauren polo women, Cheap North Face, Hollister Jeans, tiffany wedding rings, mens ralph lauren, tiffany rings, tiffany lamps, outlet polo ralph lauren, toms outlet, ralph lauren for code, Ralph Polo, Seattle Seahawks outlet, Seattle Seahawks jersey, gucci outlet store, ralph lauren pony, polo shirts ralph lauren, gucci outlet, north face outlet, tiffany alvord, hollister california, michael kors outlet, louis vuitton outlet store, north face outlet, toms promo code, iphone cases for 5C, ralph lauren promo code, louis vuitton online, wholesale toms shoes, jordan outlet, north face outlet, ralph lauren outlet, north face denali, toms outlet, gucci outlet online, ralph lauren outlet online, iphone 5C cases, cheap ralph lauren polo, ralph lauren outlet, louis vuitton Mini, ralph lauren coupon, iphone cases 5, ralph outlet, nfl store, north face outlet, toms shoes online, polo sale, nfl shop, toms outlet, ugg outlet, ralph lauren t shirt, wedding jewelry, iphone cases, iphone cases, shop Ralph lauren, toms outlet, ralph outlet, north face outlet, ralph lauren cheap, toms on sale, nfl jersey, toms outlet, iphone cases 5, ralph outlet, toms shoes outlet, north face outlet, north face outlet, toms outlet, louis vuitton Damier, ralph lauren shop, north face sale, women polo shirts, uggs outlet, north face outlet, iphone cases 5S, toms coupon codes, Hollister Outlet, Tiffany co Bangles, jordan 4, ralph lauren black, nfl outlet, michael kors store, michael kors outlet, polo lauren outlet, michael kors outlet, tiffany outlet, iphone cases 5C, wholesale toms, iphone 4 cases, the north face outlet, toms wholesale, iphone 5 cases, tiffany outlet, clothing ralph lauren, ralph lauren outlet, louis vuitton Monogram, polo shirts for men, ralph lauren factory store, north face outlet, ralph lauren online, north face outlet, louis vuitton outlet, polo ralph lauren store, Ralph Lauren Outlet, polo online, north face outlet, louis vuitton Monogram, cheap ralph polo, tiffany engagement rings, michael kors online, polo shirts men, ralph lauren store, louis vuitton outlet online, north face for sale, nfl jersey sale, juicy couture outlet, tiffany jewelry, polo ralph lauren outlet, Ralph lauren women, ralph lauren for cheap, iphone cases 5S, iphone 5S cases, silver jewelry, ralph polo, louis vuitton Leather bags, polo outlet, ralph lauren outlet, iphone 5 cases, tiffany outlet, iphone 5 cases, gucci outlet, jordan 6, polo store, juicy couture outlet, polo lauren, uggs on sale, ralph lauren coupon code, Ralph Lauren Outlet, north face outlet, polo ralph lauren men, ralph polo, nfl jerseys, ralph lauren polo shirts, north face sale, iphone 5C cases, Hollister Clothing, ralph lauren home, iphone 5S cases, iphone cases for 5C, ralph lauren outlet, tiffany outlet, polo outlet online, louis vuitton store, Seattle Seahawks sale, buy nfl jersey, the north face outlet, north face outlet, iphone cases for 5, ugg boots on sale, Seattle Seahawks online, blue ralph lauren, toms online store, iphone cases 5C, iphone cases for 5S, north face outlet, north face outlet, wholesale nfl jerseys, toms outlet, tiffany necklace
Posted @ Wednesday, October 15, 2014 12:42 AM by asd123
Post Comment
Website (optional)

Allowed tags: <a> link, <b> bold, <i> italics