TecMint.com is a community driven Linux website. Our motto is to provide an effortless howto’s to our valuable readers.

You are also welcome to join our community and can be part of our team, contributing and submitting well written article on Linux. If you have any query, please contact us by email tecmint.com [at] gmail [dot] com or use our contact form.

Install Cacti (Network Monitoring) on RHEL/CentOS 6.3/5.8 and Fedora 17-12

Cacti tool is an open source web based network monitoring and system monitoring graphing solution for IT business. Cacti enables a user to poll services at regular intervals to create graphs on resulting data using RRDtool. Generally, it is used to graph time-series data of metrics such as network bandwidth utilization, CPU load, running processes, disk space etc.

Install Cacti in Linux

Install Cacti in RHEL / CentOS / Fedora

In this how-to we are going to show you how to install and setup complete network monitoring application called Cacti using Net-SNMP tool on RHEL 6.3/6.2/6.1/6/5.8, CentOS 6.3/6.2/6.1/6/5.8 and Fedora 17,16,15,14,13,12 systems using YUM package manager tool.

Cacti Required Packages

The Cacti required following packages to be installed on your Linux operating systems like RHEL / CentOS / Fedora.

  1. Apache : A Web server to display network graphs created by PHP and RRDTool.
  2. MySQL : A Database server to store cacti information.
  3. PHP : A script module to create graphs using RRDTool.
  4. PHP-SNMP : A PHP extension for SNMP to access data.
  5. NET-SNMP : A SNMP (Simple Network Management Protocol) is used to manage network.
  6. RRDTool : A database tool to manage and retrieve time series data like CPU load, Network Bandwidth etc.

Installing Cacti Required Packages on RHEL / CentOS / Fedora

First, we need to install following dependency packages one-by-one using YUM package manager tool.

Install Apache

# yum install httpd httpd-devel

Install MySQL

# yum install mysql mysql-server

Install PHP

# yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql

Install PHP-SNMP

# yum install php-snmp

Install NET-SNMP

# yum install net-snmp-utils p net-snmp-libs php-pear-Net-SMTP

Install RRDTool

# yum install rrdtool

Staring Apache, MySQL and SNMP Services

Once you’ve installed all the required software’s for Cacti installation, lets start them one-by-one using following commands.

Starting Apache
# /etc/init.d/httpd start
OR
# service httpd start
Starting MySQL
# /etc/init.d/mysqld start
OR
# service mysqld start
Starting SNMP
# /etc/init.d/snmpd start
OR
# service snmpd start
Configure Start-up Links

Configuring Apache, MySQL and SNMP Services to start on boot.

# /sbin/chkconfig --levels 345 httpd on
# /sbin/chkconfig --levels 345 mysqld on
# /sbin/chkconfig --levels 345 snmpd on

Install Cacti on RHEL / CentOS / Fedora

Here, you need to install and enable EPEL Repository. Once you’ve enabled repository, type the following command to install Cacti application.

# yum install cacti

Sample Output:

Loaded plugins: fastestmirror, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package cacti.noarch 0:0.8.8a-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package				Arch		Version				Repository		Size
================================================================================
Installing:
 cacti                  noarch		0.8.8a-2.el6		epel            2.0 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 2.0 M
Installed size: 5.4 M
Is this ok [y/N]: y
Downloading Packages:
cacti-0.8.8a-2.el6.noarch.rpm		                         | 2.0 MB     00:40
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : cacti-0.8.8a-2.el6.noarch						1/1
  Verifying  : cacti-0.8.8a-2.el6.noarch						1/1

Installed:
  cacti.noarch 0:0.8.8a-2.el6

Complete!

Configuring MySQL Server for Cacti Installation

We need to configure MySQL for Cacti, to do this we need to set password for our newly installed MySQL server and then we will create Cacti database with user Cacti. If you’re MySQL is already password protected, then don’t need to set it again.

Set MySQL Password

To set new password for MySQL server, use the following command. (Note : This is for new MySQL installation only).

# mysqladmin -u root password YOUR-PASSWORD-HERE

Create MySQL Cacti Database

Login into MySQL server with newly created password and create Cacti database with user Cacti and set the password for it.

# mysql -u root -p
mysql> create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'your-password-here';
mysql> FLUSH privileges;
mysql> quit;

Install Cacti Tables to MySQL

Find out the database file path using RPM command, to install cacti tables into newly created Cacti database, use the following command.

# rpm -ql cacti | grep cacti.sql
Sample Output:
/usr/share/doc/cacti-0.8.7d/cacti.sql

Now we’ve of the location of Cacti.sql file, type the following command to install tables, here you need to type the Cacti user password.

mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.8a/cacti.sql

Configure MySQL settings for Cacti

Open the file called /etc/cacti/db.php with any editor.

# vi /etc/cacti/db.php

Make the following changes and save the file. Make sure you set password correctly.

/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "your-password-here";
$database_port = "3306";
$database_ssl = false;

Configuring Apache Server for Cacti Installation

Open file called /etc/httpd/conf.d/cacti.conf with your choice of editor.

# vi /etc/httpd/conf.d/cacti.conf

You need to enabled access to Cacti application for your local network or per IP level. For example we’ve enabled access to our local LAN network 172.16.16.0/20. In your case, it would be different.

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

Finally, restart the Apache service.

# /etc/init.d/httpd restart
OR
# service httpd restart

Setting Cron for Cacti

Open file /etc/cron.d/cacti.

# vi /etc/cron.d/cacti

Uncomment the following line. The poller.php script runs every 5mins and collects data of known host which is used by Cacti application to display graphs.

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

Running Cacti Installer Setup

Finally, Cacti is ready, just go to http://YOUR-IP-HERE/cacti/ & follow the installer instruction through the following screens. Click Next button.

Cacti Installer Screen

Cacti Setup Screen

Please choose installation Type as “New Install“.

Cacti New Install Setup

Select Cacti New Install

Make sure all the following values are correct before continuing. Click Finish button.

Cacti Installation

Cacti Installation Directories

Cacti Login Screen, enter username as admin and password as admin.

Cacti Login Screen

Cacti Login Screen

Once you’ve entered username and password, it will ask you to enter a new password for cacti.

Set Cacti Password

Cacti Force Password Screen

Cacti Console Screen.

Cacti Console

Cacti Console Screen

How to Create New Graphs

To create graphs, Click on New Graphs –> Select Host –> Select SNMPInterface Statistics and Select a graph type In/Out Bits. Click on Create button. Please refer screen below.

Create Graphs in Cacti

How to Create Graphs in Cacti

For more information and usage please visit the Cacti Page.


69 Responses

  1. Before step “Running Cacti Installer Setup” you need to open for HTTP in IPTABLES firewall….

    nano /etc/sysconfig/iptables

    Add the following:

    -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

    and restart IPTABLES:

    service iptables restart

  2. jon says:

    thanks for the tutorial bro ; )

  3. g3 says:

    Great Instructions!!!! Do you have anyting on adding plugins like routerconfigs or realtime

  4. Venkat says:

    Hi,

    I have installed cacti in CentOS. Currently, the installation was successful, but it is not allowing me to go to the next screen after login. After I give admin/admin, the page is getting refreshed and its not moving to the next screen, where we can see the “force password change” page. Please help in giving some solution to it.

    • Ravi Saive says:

      @Venkat,

      I think you have login session problem, set 777 writes to /tmp folder and /var/lib/php/session. it should work.

    • Sahil says:

      Dear Venkat,

      Please give the new password and confirm password for cacti use.
      Hope this will be solve your issue.
      Thanks…….

  5. Ehsan says:

    Thank you Very much . I have configured Cacti with out any error.

  6. robert says:

    Can anyone help me in setting up a cacti for monitor only my network devices. Please if any one could be me with the commands and the interface also. Console screen

  7. Abbas says:

    Hey , Really great instruction installing cacti.However I am facing a little problem.
    When I reach to the point of Running cacti installer set up I get the following error:

    Forbidden

    You don’t have permission to access /cacti on this server.
    Apache/2.2.15 (CentOS) Server at localhost Port 80

    P.S : I am new at unix

    • Ravi Saive says:

      @Abbas,

      Did you added Allow from 127.0.0.1 in /etc/httpd/conf.d/cacti.conf file to allow access to localhost?

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

      After that, restart httpd service. It will fix the problem.

      service httpd start 
      
  8. Abbas says:

    I have tried that this moment, but still the same error
    is there any service that should be restarted upon this config ?

  9. Abbas says:

    Ravi,its done,
    I was using localhost/cacti so I changed to use my-local-IP/cacti and edited my proxy settings

    1 more question for now
    which username and password I must use

  10. Abbas says:

    Well, I did not notice the default ones
    Thanks man :)
    I have logged in

  11. Abbas says:

    I have only two options regarding Graph types :
    *Graph templated base
    *Unix-Get mounted partitions

  12. simon says:

    please use this default user name admin and password admin. it works

  13. safa says:

    Hi!
    Please help me!

    Alias /cacti /usr/share/cacti

    # httpd 2.4
    Require host localhost

    # httpd 2.2
    Order deny,allow
    Deny from all
    Allow from 172.16.16.0/20
    in this section , when I restart apache it didn’t start and give me a error that Reqire or Order or Deny or Allow not allowed here

  14. Marius says:

    Did nobody got this error message:

    Error: Package: php-devel-5.3.3-14.el6_3.i686 (updates)
    Requires: php = 5.3.3-14.el6_3
    Installed: php-5.4.10-1.el6.remi.i686 (@remi)
    php = 5.4.10-1.el6.remi
    Available: php-5.3.3-3.el6_2.8.i686 (base)
    php = 5.3.3-3.el6_2.8
    Available: php-5.3.3-14.el6_3.i686 (updates)
    php = 5.3.3-14.el6_3
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest

    So I did, someone knows how to resolve this ?

    Thanks

    • Ravi Saive says:

      You have older version php which is conflicting with php 5.4, first remove the older php with the following commands.

      # yum -y erase php php-devel php-common
      

      and then try again…

      • Marius says:

        Thanks Ravi for your quick response,

        That is going well so far, but when I try to startup the cacti install webinterface I got the following error message:

        FATAL: Cannot connect to MYsql server on myhostname, Please make sure you have specified a valid mysql databasename in ‘/include/config.php’

        • Ravi Saive says:

          Please put correct database name, localhost and user details in config.php.

          • Scott says:

            I am receiving the same error,

            Fatal: Cannot connect to MySql Server on my hostname, Please make sure you have specified a valid mysql database name in ‘/include/config.php’

            I understand I need to vi to config.php and apply the correct parameters; however can someone tell me where to find this file.

            I assume it was under /var/www/html/cacti but the path mention is not a valid path

          • Ravi Saive says:

            use the /etc/cacti/db.php file and add the correct mysql parameters.

  15. safa says:

    hello!
    I configure httpd and mysql and cron but when i type in browser ,i just view a empty page

  16. Johnny says:

    Hey i’ve tried this 3 times, and each time Cacti works but no graphs show, like no image at all, not even a broken image link just no graph image, Any ideas?

    • Johnny says:

      Poller shows this when i run it:SYSTEM STATS: Time:0.5038 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:1 RRDsProcessed:0

      Is there some permissions or something that needs to be set for this to work?

  17. Asking questions are in fact nice thing if you are
    not understanding anything fully, but this piece of writing presents nice understanding even.

  18. duonghelio says:

    help me !
    I don’n log on to Cacti

  19. duonghelio says:

    Thank so much

  20. Thomas says:

    Hi,
    am getting an error on the web browser:
    Forbidden

    You don’t have permission to access /cacti/ on this server.
    Apache/2.2.3 (CentOS) Server at 197.231.244.21 Port 80

    My cacti.conf looks like this:

    Alias /cacti /var/www/html/cacti/

    Order Deny,Allow
    Deny from all
    Allow from 172.227.244.0/22

  21. Thomas says:

    Hi Ravi,
    Sorry about the first post, i have made corrections:

    My cacti.conf looks like this:
    Alias /cacti /var/www/html/cacti/
    Order Deny,Allow
    Deny from all
    Allow from 172.227.244.21

    but still:

    Forbidden
    You don’t have permission to access /cacti/ on this server.
    Apache/2.2.3 (CentOS) Server at 172.227.244.21 Port 80

    both mysqld and httpd services are running.

    • Ravi Saive says:

      After making corrections, have you restarted Apache? If yes, then you must define proper IP address in Allow section. Have you tried from the localhost?

      • Thomas says:

        Yes i did the needful, both localhost and my IP are tripping. if i type my IP or localhost in the browser the apache test web page opens nicely.

      • Thasleem says:

        Hi,
        me too having same problem. tried using the ip and localhost both with no luck.restarted the HTTPD service too

  22. Andy says:

    Hi,

    All installed as per these excellent instructions however I do not get any graph images showing – just a broken link where the image should be showing.

    It looks like a possible permissions issue but can not see where it could be. The yum install cacti placed the website directory structure /usr/share/cacti as with root permissions and everything else appears to work fine.

    Cent OS 6.3 clean and minimal install then installed as per your instructions.

    Any ideas?

    Thanks

    Andy

  23. Daniel says:

    Forbidden

    You don’t have permission to access /cacti on this server.

    Don’t Work

  24. Shinobi says:

    Why this tutorial not including configure snmp for cacti. I think cacti is 100% useful if it configure using snmp for trap any statistic interface both from the host and remote host :)

  25. Ariel Chiong says:

    Do You have any tutorial regarding on plugins, like the “monitor tab maybe”

    thanks

  26. Gopi says:

    Thanks Ravi for your excellent instructions …
    I am still getting “FATAL: Cannot connect to MySQL server on ‘localhost’. Please make sure you have specified a valid MySQL database name in ‘include/config.php’ ”

    I am sure i have configured db.php properly as per the right credentials…
    —–
    $database_type = “mysql”;
    $database_default = “cacti”;
    $database_hostname = “localhost”;
    $database_username = “cacti”;
    $database_password = “titan#12″;
    $database_port = “3306″;
    $database_ssl = false;

    Ravi, Please help me in this case…

    • Ravi Saive says:

      Is MySQL service is started? and port is open on firewall? can you post the output of the following command.

      telnet localhost 3306
      
      • Gopi says:

        Thank you Ravi for the prompt response.

        Below is the output of the given command.
        o/p: -bash: telnet: command not found

        in my box , the db.php is residing in “/var/www/cacti”

        Thanks in advance…
        Gopi.

        • Ravi Saive says:

          telnet package is not installed, install it tbis way.

          yum install telnet
          

          And then again post the output command.

          • Gopi says:

            Yeah! i will try and update the status…

            Thnx/Gopi

          • Gopi says:

            Ravi, installed telnet and below is the output…
            ——————————————————————
            [root@XXXXXXXXX~]# telnet localhost 3306
            Trying 127.0.0.1…
            Connected to localhost.
            Escape character is ‘^]’.
            4
            5.0.95?.7i+:~/l,S=rLc/^m)!jrConnection closed by foreign host.
            [root@sbcloudlymem02 ~]#

          • Gopi says:

            Below is the output after install
            …….

            [root@machineName ~]# yum install telnet
            Loaded plugins: fastestmirror
            Loading mirror speeds from cached hostfile
            * addons: centos.mirror.nac.net
            * base: centos.mirror.nac.net
            * extras: centos.vipernetworksystems.com
            * rpmforge: mirror.hmc.edu
            * updates: mirror.wiredtree.com
            Setting up Install Process
            Resolving Dependencies
            –> Running transaction check
            —> Package telnet.i386 1:0.17-41.el5 set to be updated
            –> Finished Dependency Resolution

            Dependencies Resolved

            ================================================================================
            Package Arch Version Repository Size
            ================================================================================
            Installing:
            telnet i386 1:0.17-41.el5 base 57 k

            Transaction Summary
            ================================================================================
            Install 1 Package(s)
            Update 0 Package(s)
            Remove 0 Package(s)

            Total download size: 57 k
            Is this ok [y/N]: y
            Downloading Packages:
            telnet-0.17-41.el5.i386.rpm | 57 kB 00:00
            Running rpm_check_debug
            Running Transaction Test
            Finished Transaction Test
            Transaction Test Succeeded
            Running Transaction
            Installing : telnet 1/1

            Installed:
            telnet.i386 1:0.17-41.el5

            Complete!
            [root@machineName ~]# telnet localhost 3306
            Trying 127.0.0.1…
            Connected to localhost.
            Escape character is ‘^]’.
            4
            5.0.95?.7i+:~/l,S=rLc/^m)!jrConnection closed by foreign host.
            [root@machineName ~]#

          • Ravi Saive says:

            Everything seems to be fine, I don’t know why you getting such error. If you don’t mind can I have your server IP address to check from the browser. Or create a testdb.php file under your website root directory and add the following lines and replace MySQL settings as per your needs and browse the file and post the output.

            <?php
            ob_start();
            define('server_name','172.16.25.126');
            //define('server_name','localhost');
            define('user_name','root');
            define('user_password','tecmint');
            define('dbname','dbname');
            $conn = mysql_pconnect(server_name,user_name,user_password);
            if($conn)
            echo "Connection establish<br>";
            else
            echo "Connection Failed<br>".mysql_error();
            $db = mysql_select_db(dbname,$conn);
            if($db)
            echo "DB establish<br>";
            else
            echo "DB Failed<br>".mysql_error();
            ?>
            
  27. sheltjo6 says:

    Great instructions. Finally was able to install and run Cacti on a CentOS linux box.

    I ran into a problem when installing Cacti tables to MySQL.
    I had to change the permissions on the cacti.sql file inorder to install the tables.

    Other than that, this recipe works great.
    Thanks for sharing.

  28. Ariel Chiong says:

    Hi,

    Do you know where to configure about email notifications? for example the system is up or down, you’ll be notified something like that.

    thanks in advanced.

  29. jaswant says:

    Sir,

    I have follow all steps but i am getting error

    Forbidden

    You don’t have permission to access /cacti on this server.

    please help me

    please reply in my email id

  30. Rich says:

    Hi Ravi,

    Great instructions/notes.

    I’ve gotten up to the point of running cacti in my browser – getting the ole 403 Forbidden message.

    I’m running Fedora 18 in a VM. My host OS is Windows 7; and I’m running VirtualBox (in case this makes a difference)

    Anyway, I’ve specified my guest/Fedora IP in …/cacti.conf; restarted httpd.service. I’ve changed it back to 127.0.0.1 and restarted httpd.service… I’m also running Firewall and selected http and https as trusted for the current zone and added 3306 to “ports”.
    Still no luck. Iptables.service is not running.

    Any suggestions?
    -Rich

  31. Hossein says:

    [root@test ~]# yum install cacti
    Loaded plugins: fastestmirror, security
    Loading mirror speeds from cached hostfile
    * base: less.cogeco.net
    * extras: less.cogeco.net
    * updates: centos.bhs.mirrors.ovh.net
    Excluding Packages in global exclude list
    Finished
    Setting up Install Process
    No package cacti available.
    Nothing to do
    [root@test ~]#

  32. Xu says:

    I follow every step. But no images shows on the screen, even no warning, I wonder why?

  33. Ariel Chiong says:

    Hi, is Cacti capable of monitoring storage? monitor your hard disk and it will send a email that if it is near full?

Leave a Reply

Proudly designed by Tecmint.com.