Home > Linux, Monitoring > Installing Cacti on CentOS Linux 5.4

Installing Cacti on CentOS Linux 5.4

Cacti is a web frontend graphing tool for RRDtool.  You can use it to create custom graphs for network and host statistics provided by services such as SNMP.  In this post I will guide you through the process of installing Cacti 0.8.7e on CentOS Linux 5.4.

According to the documentation Cacti may have problems working correctly with SELinux.  On servers I generally disable this feature.  I have not tried to install it on a system with SELinux enabled.  The documentation has details on how to configure SELinux for Cacti if you’d like to try and leave it enabled.  To disable SELinux, edit the section of the /etc/selinux/config as follows:

#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:

Save the changes, reboot your system, and log back in.

I prefer to use yum and RPM’s if they are available.  Extra Packages for Enterprise Linux (EPEL) has a Cacti package available in their yum repository.  I’ll activate the EPEL repository, bear in mind that I’m using the 32-bit version of CentOS:

shell# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/ \
> epel-release-5-4.noarch.rpm

Now time to install Cacti.  We’ll also include the packages for the Apache and MySQL daemons.  The net-snmp-utils package is not installed as a dependency by yum when we install Cacti, so we’ll explicitly include as well:

shell# yum install cacti httpd mysql-server net-snmp-utils

If MySQL was installed for the first time running yum above, it’s a good idea to set a default password for the root user in MySQL now.  Let’s verify the MySQL and Apache daemons are set to start at boot and start them now:

shell# chkconfig mysqld on
shell# chkconfig httpd on
shell# service mysqld start
shell# service httpd start

Now we’ll set the password for the root inside MySQL:

shell# mysqladmin -u root password NewPassword

Time to create the MySQL database for Cacti, we specify the “-p” option so mysqladmin will prompt for us for new password we entered above:

shell# mysqladmin -u root -p create cacti

Import the schema for the Cacti database:

shell# mysql -u root -p cacti < /usr/share/doc/cacti-0.8.7e/cacti.sql

Now it’s time to create a MySQL user specifically for Cacti to use.  While this is not required it is best to limit Cacti’s access to our MySQL database:

shell# mysql -u root -p mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'Passwrd';
mysql> flush privileges;
mysql> exit

Now we need to edit the /usr/share/cacti/include/config.php file and enter the correct database user and password information:

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

Now we need to install the cron daemon and crontabs packages so that we can poll the device periodically we are collecting statistics from:

shell# yum install vixie-cron crontabs

Edit the /etc/crontab file and add the following line at the end:

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

Next we’ll edit the directory directive in the Cacti configuration file for apache (/etc/httpd/conf.d/cacti.conf) to allow access to the web interface  from other hosts besides localhost.  Change the Allow directive to suit your network:

<Directory /usr/share/cacti/>
Order Deny,Allow
Deny from all
Allow from 192.168.0.0/16
</Directory>

Restart the Apache web server to apply our configuration changes:

shell# service httpd restart
Advertisements

Pages: 1 2

Categories: Linux, Monitoring Tags: ,
  1. Greg
    April 3, 2010 at 3:07 am

    Thanks loads! This was extremely useful and easy to follow.

  2. May 31, 2010 at 9:17 pm

    Wow am I literally the only comment to this awesome read!?

  3. Deni W
    September 25, 2010 at 11:35 pm

    Great and very useful tutorial! Thank you very much.

  4. flatpack
    November 15, 2010 at 3:32 pm

    when i try to install cacti by this command yum install cacti it says nothing to do, so i think there is no package called cacti in repo.

    • November 16, 2010 at 1:39 am

      Hi Wasim,

      Things that I would check would be to make sure that the EPEL repo was added successfully and also make sure that it is enabled (I can’t remember if it does this by default). The file containing the repo info is “/etc/yum.repos.d/epel.repo”. I just checked and the cacti package is available for me, and I am running CentOS 5 x86.

      Best Wishes,

      Aaron

  5. flatpack
    November 17, 2010 at 1:44 pm

    awalrath thanks for reply, by running this command fixed that problem for me:
    $ rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

    now another problem, no graph is showing up, this may be related to permission issue. any idea?
    i m using CentOS 5.4

    • November 20, 2010 at 5:33 pm

      I updated the hyperlink in the post for the EPEL repo, thanks for including it.

      I seem to remember at some point having difficulty with graphs being displayed too, I think I had to wait a little while for them to show up. I have another post on monitoring Windows 2008 R2 with Cacti and SNMP, if you have Windows in your environment you could try that and graphs should show up.

      Best Wishes,

      Aaron

  6. TaintedSquirrel
    March 24, 2011 at 4:40 pm

    This tutorial was awesome, thank you very much! It is still a completely valid walkthrough for CentOS 5.5 (32bit – i386)/ Cacti 0.8.7f.

  7. August 3, 2011 at 12:00 pm

    Thank you. Very useful

  1. May 23, 2010 at 12:21 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: