Install Cacti on CentOS 7– The Definitive Guide in 2017


Cacti is one of the most robust  monitoring tool available in the market. It has a lot of features and options that able to give you a complete visibility for your infrastructure. In this guide I will walk through installing Cacti on CentOS 7, Configuring the MariaDB (The new Database for the CentOS 7 ), Adding few devices and finally plotting the result. Also  I will cover some troubleshooting points during the configuration. So Let’s start


Installation Steps

Step 1: Modify the date to be UTC instead of EET or any other format (cacti may print an error you don’t do that)

#rm -f /etc/localtime
#ln -s /usr/share/zoneinfo/UTC /etc/localtime
[root@nom-cs2 ~]# date
Tue Feb 28 13:37:53 UTC 2017 

Step 2:  Install Supplementary packages (Apache, DB,..etc)

# yum install httpd httpd-devel mariadb-server \

php-mysql php-pear php-common php-gd php-devel \

php php-mbstring php-cli epel-release -y


Step 3:  Now install the rrdtool (which is graphing backend for cacti)

# yum install php-snmp net-snmp-utils net-snmp-libs rrdtool -y 


Step 4:  Start the Services and Enable them at boot time

systemctl start httpd.service

systemctl start mariadb.service

systemctl start snmpd.service

systemctl enable httpd.service

systemctl enable mariadb.service

systemctl enable snmpd.service


Step 5:  Setup MariaDB password for the root username

mysqladmin -u root password access123

Step 6:  Create Cacti DB and create a cacti username

mysql -u root -p

Password: <access123>

MariaDB [(none)]> create database cacti;

MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'access123';

MariaDB [(none)]> FLUSH privileges;

MariaDB [(none)]> quit;

Step 7:  Install Cacti from Epel Release


yum install cacti –y

Step 8:  Import the tables into the Cacti DB

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

Step 9: Edit the Cacti DB Configuration


vim /etc/cacti/db.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "access123";

$database_port = "3306";

$database_ssl = false;

Step 10: Configure HTTP Access

vim /etc/httpd/conf.d/cacti.conf


<Directory /usr/share/cacti/>

<IfModule mod_authz_core.c>

# httpd 2.4

#Require host localhost

Require all granted

#Require host


<IfModule !mod_authz_core.c>

# httpd 2.2

Order deny,allow

Deny from all

Allow from all

#Allow from



Step 11:  Restart HTTPD process for the change to take effect

systemctl restart httpd.service

Step 12:  Create the log file where the cacti will store and write it’s file

mkdir -p /var/log/cacti

Step 13:  Create the Log File inside the above directory

cd /var/log/cacti/

touch cacti.log

Step 14:  Uncomment the Cron Job for the poller in the following file

vim /etc/cron.d/cacti

Step 15:  Go to http://YOUR-IP-ADDRESS/cacti/ and just follow the Installer instruction, Just simple steps and series of Next




Default Login is admin/admin


Step 16:  Change the Permission on installation to 777 for all files to avoid any errors (I know may be not the smart thing in production environment)


cd /usr/share/cacti/

chmod 777 -R *

Step 17: Test the CMD and Poller scripts

php /usr/share/cacti/cmd.php

php /usr/share/cacti/poller.php

Step 18:  Add New Device




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 this a suggestion from Cacti to the added host.



Select all available Templates and click on Create


Then choose the legend for each created graph and then click on create



Also you can Create a new Graph from available ones


Cisco Router




Note: It takes around 15 minutes for Cacti to populate new graphs. There are not alternatives to being patient.

You can create a graph Tree





Add Graphs to created Header


Final View



CPU Graphing

CPU can exceed the value of 100% if you’ve multiple cores in your servers and hence a value of nan will be shown in your graph

Here’s how to fix it and get it working. First Navigate to the following Path

Console> Data Templates > CPU Templates


Increase this value to cover all of your cores


Also fix the values in your rrd files

cd /usr/share/cacti/rra

rrdtool tune localhost_cpu_nice_12.rrd --maximum cpu_nice:900%

rrdtool tune localhost_cpu_user_14.rrd --maximum cpu_user:900%

rrdtool tune localhost_cpu_system_13.rrd --maximum cpu_system:900%

Repeat for Memory Template


Also it’s worth to go to RR directory inside the cacti and change the permissions  to 777 (Again, Dont do that in production)

[root@nom-cs2 rra]# ls -htlr

total 620K

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_cpu_user_13.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_cpu_system_12.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_cpu_user_10.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_cpu_system_9.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_cpu_nice_8.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_cpu_nice_11.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_mem_buffers_14.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_mem_swap_15.rrd

-rwxrwxrwx. 1 cacti cacti 139K Feb 28 19:00 cactiserver_load_1min_16.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_users_17.rrd

-rwxrwxrwx. 1 cacti cacti 47K Feb 28 19:00 cactiserver_proc_18.rrd

Finally You can Find Database size that consumed by the cacti till now

mysql -u cacti -p

Enter password:<access123>

SELECT table_schema "cacti",

Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"

FROM information_schema.tables

GROUP BY table_schema;


| cacti | DB Size in MB |


| cacti | 0.6 |

| information_schema | 0.1 |


Client Host Configuration

In this section, I will guide you through configuring the  clients with SNMP configuration so they will be ready to be connected with Cacti

Step 1: Install SNMP

yum install net-snmp

Step 2: Enable the SNMP on client host

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.old

echo "rocommunity public" > /etc/snmp/snmpd.conf

service snmpd restart

chkconfig snmpd on

Step 3: Make sure you can get all SNMP OIDs  by running the below command

snmpwalk -c public -v1

Or use SNMP Version2

snmpwalk -c public -v2c

If you need to add additional security to monitoring by specifying only the cacti host, add the below line

vim /etc/snmp/snmpd.conf

Step 1:  First, map the community name “public” into a “security name”

com2sec local localhost public

com2sec mynetwork public

Step 2: map the security name into a group name:

group MyRWGroup v1 local

group MyRWGroup v2c local

group MyROGroup v1 mynetwork

group MyROGroup v2c mynetwork

Step 3: create a view for us to let the group have rights to:

# incl/excl subtree mask

view all included .1 80

Step 4:  Finally, grant the group read-only access to the systemview view.

# group context sec.model sec.level prefix read write notif

access MyROGroup "" any noauth exact all none none

access MyRWGroup "" any noauth exact all all none

syslocation Linux, Home Linux Router.

syscontact BasimAly <>

Step 5: Restart the service

service snmpd restart


That’s it. I hope this has been informative for your and I’d like to thank you for reading.


2 thoughts on “Install Cacti on CentOS 7– The Definitive Guide in 2017

  1. i found out that i have to install the spine manually done installing it and configuring it
    im not getting how to set spine file location

    second main issue im facing is that snmp queries not writable error at directory permissions checks screen

    i saw a video a person entered command
    # chown -R apache:apache cacti
    and the issue got resolved ..but he entered this command in a directory names as “html” . may be he created it or whatever ..i cant find this directory

    and in one post i found a person mentioned command similar to it
    #chmod u+s spine
    #chown root.root spine

    please help

  2. Everything was fine but as i changed my Time zone the graph is not updating anymore..
    im able to see the graphs but its not showing any slopes,what to do ??

Share you opinion to benefit others :)

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s