How to Install Cacti on CentOS 6.2 using EPEL Repository

Share this Article :

Cacti is a complete network graphing solution that useful for network administrator to monitor their network bandwidth. It collect SNMP data as well as other data such as system load, network link status, hard disk space and etc.

From Cacti official site :

Cacti is a complete network graphing solution designed to harness the power of RRDTool’s data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.

In this post, i will show you on how to install Cacti on linux CentOS 6.2 server. This tutorial assumed that you already installed LAMP (Linux CentOS 6.2 x86, Apache httpd server, Mysql server and PHP) server.

How to Install and Configure EPEL Repository on CentOS 6.2

Cacti is very easy to use and have the following features if it properly configured:

  • Graphs
  • Data Sources
  • Data Gathering
  • Graph Display
  • User Management

1. Login to your CentOS 6.2 server as a root and install the following packages :

[[email protected] ~]# yum install cacti httpd mysql-server mysql php-common php-mysql php-pear net-snmp php-gd php-devel php php-mbstring php-cli net-snmp-utils php-snmp php-pear-Net-SMTP -y

2. Make sure all these software/packages has been installed :

Package cacti-0.8.7i-2.el6.noarch already installed and latest version
Package httpd-2.2.15-15.el6.centos.1.i686 already installed and latest version
Package mysql-server-5.1.61-1.el6_2.1.i686 already installed and latest version
Package mysql-5.1.61-1.el6_2.1.i686 already installed and latest version
Package php-common-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-mysql-5.3.3-3.el6_2.6.i686 already installed and latest version
Package 1:php-pear-1.9.4-4.el6.noarch already installed and latest version
Package 1:net-snmp-5.5-37.el6_2.1.i686 already installed and latest version
Package php-gd-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-devel-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-mbstring-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-cli-5.3.3-3.el6_2.6.i686 already installed and latest version
Package 1:net-snmp-utils-5.5-37.el6_2.1.i686 already installed and latest version
Package php-snmp-5.3.3-3.el6_2.6.i686 already installed and latest version
Package php-pear-Net-SMTP-1.6.1-1.el6.noarch already installed and latest version

3. Starting the database :

[[email protected] ~]# service mysqld start
Starting mysqld:                                           [  OK  ]

4. Login to mysql server and create the following database and user :

Database’s Name : cactidb
Database’s User : cactiuser
Database’s Password : cactipassword

[[email protected] ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE cactidb;
Query OK, 1 row affected (0.00 sec)

mysql> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactipassword';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON cactidb.* to [email protected];
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW GRANTS FOR 'cactiuser'@'localhost';
+------------------------------------------------------------------------------------------------------------------+
| Grants for [email protected]                                                                                   |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'cactiuser'@'localhost' IDENTIFIED BY PASSWORD '*6FF226B3BB20712FB42564D21683F5A0173DDD16' |
| GRANT ALL PRIVILEGES ON `cactidb`.* TO 'cactiuser'@'localhost'                                                   |
+------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> exit
Bye

5. Find out cacti.sql path using the following command :

[[email protected] ~]# rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.7i/cacti.sql

6. Populate and import the cacti database :

[[email protected] ~]# /usr/bin/mysql cactidb -u cactiuser -p < /usr/share/doc/cacti-0.8.7i/cacti.sql
Enter password:

7. Configure cacti :

[[email protected] ~]# vi /etc/cacti/db.php

Update the following details meet your configuration :

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipassword";
$database_port = "3306";
$database_ssl = false;

Original configuration

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

Change the configuration to :

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

8. Start the apache httpd service if you haven't start :

[[email protected] ~]# /etc/rc.d/init.d/httpd start
Starting httpd:                                            [  OK  ]

or just reload to update it:

[[email protected] ~]# /etc/rc.d/init.d/httpd reload
Reloading httpd:

9. Make httpd and mysql service auto start at boot :

[[email protected] ~]# chkconfig httpd on
[[email protected] ~]# chkconfig mysqld on

10. Setting up the crontab :

Check where is poller.php :

[[email protected] ~]# ls /usr/share/cacti/
about.php                graph_image.php             host_templates.php   rra
auth_changepassword.php  graph.php                   images               rra.php
auth_login.php           graph_settings.php          include              scripts
cdef.php                 graphs_items.php            index.php            script_server.php
cli                      graphs_new.php              install              settings.php
cmd.php                  graphs.php                  lib                  templates_export.php
color.php                graph_templates_inputs.php  log                  templates_import.php
data_input.php           graph_templates_items.php   logout.php           tree.php
data_queries.php         graph_templates.php         poller_commands.php  user_admin.php
data_sources.php         graph_view.php              poller_export.php    utilities.php
data_templates.php       graph_xport.php             poller.php
gprint_presets.php       host.php                    resource
[[email protected] ~]# crontab -e
# Used to update Cacti
*/5 * * * * /usr/share/cacti/poller.php >> /var/log/cacti 2>&1

How to Setup and Configure Cacti on CentOS 6.2

2 Comments

  1. KAGE
  2. KAGE

Leave a Reply