How​ ​to​ ​Install​ ​Cacti​ ​Monitoring​ ​on​ ​CentOS 7

r00t November 27, 2017

​Install​ ​Cacti​ ​Monitoring​ ​on​ ​CentOS 7

In this tutorial we’ll learn how to install Cacti​ ​Monitoring on CentOS 7. We will also install and configure its prerequisites. Cacti is a complete network graphing solution designed with RRDTool’s data storage and graphing functionality. It may chart network bandwidths using SNMP, shell or Perl scripts. RRDtool is a software created by the Swiss Tobi Oeticker who was already the inventor of the renowned MRTG. RRDtool is developed utilizing the “C” programming language and it stores the collected data on “. Rrd” files. The number of records in a “. Rrd” document never increases, meaning that old documents are frequently removed. This implies that one obtains precise figures for recent logged information, whereas data based on very old information will be mean value approximations. By default, you can have daily, weekly, monthly and annual charts.

I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

​Install​ ​Cacti​ ​Monitoring​ ​on​ ​CentOS 7

Step 1. First, ensure your system is fully up-to-date by running the following:

yum -y update
yum -y install epel-release

Step 2. Installing LAMP on Ubuntu 16.04.

You should check out this LAMP stack install tutorial for CentOS 7, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on.

Step 3. ​Install​ ​Cacti​ ​Monitoring​.

First, Install​ ​SNMP​ ​and​ ​SNMP​ ​and​ ​RRDtools:

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

Now​ ​use​ ​the​ ​following​ ​command​ ​to​ ​install​ ​Cacti:

yum install cacti

Start HTTPD, MySQL and SNMP service enter following command:

systemctl start httpd.service
systemctl start mariadb.service
systemctl start snmpd.service

Step 4. Configure Cacti database.

First, ceate cacti database:

# mysql -u root -p
MariaDB [(none)]> create database cacti;
MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cactipass';
MariaDB [(none)]> FLUSH privileges;
MariaDB [(none)]> quit;

Now, import cacti database tables from the cacti.sql file. First locate cacti.sql file:

# rpm -ql cacti|grep cacti.sql
/usr/share/doc/cacti-0.8.8b/cacti.sql

Import tables to cacti database:

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

Open /etc/cacti/db.php file using nano of nano editor and edit the below lines:

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

Step 5. Adding firewall rules for Cacti.

Following settings will add access rules to http and https from outside:

firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload

Step 6. Configuring Apache Server for Cacti.

Open file called /etc/httpd/conf.d/cacti.conf:

nano /etc/httpd/conf.d/cacti.conf

Now edit the “Allow From” line, Either set to ALL or enter your LAN subnet to allow access to cacti:

Alias /cacti /usr/share/cacti

<Directory /usr/share/cacti/>
 <IfModule mod_authz_core.c>
 # httpd 2.4
 Require host 192.168.0.0/24
 </IfModule>
 <IfModule !mod_authz_core.c>
 # httpd 2.2
 Order deny,allow
 Deny from all
 Allow from 192.168.0.0/24
 </IfModule>
</Directory>

Finally, restart the Apache service:

systemctl restart httpd.service

Step 7. Set cron for Cacti.

Open /etc/cron.d/cacti file and uncomment the line:

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

Step 8. Cacti Web Installation Setup.

Cacti will be accessible on port 80 by default, this can be changed within your web server configuration. As installation is now successful, you may proceed to navigate to http://server-ip/cacti or http://server-hostname/cacti and complete the required the steps to finish the installation.

Congratulation’s! You have successfully install and configured Cacti​ on your CentOS 7 server. Thanks for using this tutorial for installing Cacti​ ​Monitoring on CentOS 7 system.

Leave a Comment

Comments are closed.