Cacti is an open-source, web-based network monitoring and graphing tool used to get a graph data such as CPU usage, memory usage, network bandwidth utilization, and more. It can graph the network traffic by polling a router or switch using SNMP protocol.
In this article will show how to install Cacti on CentOS 7 or RHEL 7. At the time of writing this document, the latest Cacti version that available to download is 1.1.10.
In this tutorial, it is supposed that:
a. You have already install RHEL/CentOS 7 Linux server up and running. In case that you don’t, you would probably like to read this link. Minimal RHEL/CentOS 7 Installation With Logical Volume Manager (LVM).
b. You have already done the initial server setup. Please refer to this link Minimal RHEL/CentOS 7 Initial Server Setup.
3. Install and Configure Database for Cacti Application
In CentOS 7, MySQl is moved to MariaDB, execute the following command to install MariaDB.
# yum -y install mariadb-server mariadb-devel
Enable MariaDB service to start it a the system boot and start its service.
# systemctl enable mariadb # systemctl start mariadb
Now let do the security hardening of MariaDB by execute the following command.
We need to create a database and a user for Cacti application and grant it all database privileges.
# mysql -u root -p > create database cactidb; > create user 'cactiuser'@'localhost' identified by 'P@ssword01'; > grant all privileges on cactidb.* to cactiuser@localhost; > flush privileges;
4. Installing Cacti Application
To install Cacti web application, we need to install some mandatory packages as the following first.
# yum -y install php php-cli php-mysql net-snmp-utils rrdtool php-snmp gcc net-snmp-devel autoconf automake libtool dos2unix wget help2man php-gd php-ldap php-pear php-common php-devel php-mbstring net-snmp-utils net-snmp-libs httpd
Enable Apache service to start it a the system boot and start its service.
# systemctl enable httpd # systemctl start httpd
Enable SNMP service to start it a the system boot and start its service.
# systemctl enable snmpd # systemctl start snmpd
Let move to the installation directory for Cacti application, /var/www, download and extract it.
# cd /var/www # wget http://www.cacti.net/downloads/cacti-1.1.10.tar.gz # tar -xzvf cacti-1.1.10.tar.gz
It is recommended to create a symbolic link to the extracted directory of Cacti application “cacti-1.1.10”. So, it will make us easy to upgrades Cacti to a newer versions.
# ln -s cacti-1.1.10 cacti
Also, we need to create a user for Cacti application and make sure that the permissions on the log and rra directories are set correctly as the following.
# adduser -d /var/www/cacti -s /sbin/nologin cacti # chown -R apache:apache /var/www/cacti-1.1.10 # chown -R cacti /var/www/cacti-1.1.10/rra
Now we need to add a cron entry for a 1 minute polling interval of Cacti application using the following command.
# vim /etc/cron.d/cacti */1 * * * * cacti php /var/www/cacti/poller.php &>/dev/null
Now, let import Cacti application database into the database created using the following command.
# mysql -p cactidb < /var/www/cacti/cacti.sql
Next, we need to change some settings for database credentials in configuration file of Cacti application.
# vim /var/www/cacti/include/config.php $database_type = 'mysql'; $database_default = 'cactidb'; $database_hostname = 'localhost'; $database_username = 'cactiuser'; $database_password = 'P@ssword01'; $database_port = '3306'; $database_ssl = false;
Next, we need to open HTTP port 80 on IPTables.
# vim /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT # systemctl restart iptables # iptables -L -n -v
Usually, the default PHP installation usually has not configured the correct timezone or php error reporting. While not required to run Cacti, it’s highly recommended to enable error reporting to syslog for troubleshooting issues with plugins or other scripts. Edit file /etc/php.ini as the following.
# vim /etc/php.ini date.timezone = Asia/Phnom_Penh log_errors = syslog
Then, we need to restart Apache service.
# systemctl restart httpd
We also need to disable SELinux.
# vim /etc/selinux/config SELINUX=disabled # reboot
5. Configure VHost for Cacti Application
To create a VHost for Cacti application, create a *.conf file in directory /etc/httpd/conf.d as the following.
# vim /etc/httpd/conf.d/cacti.conf <VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName cacti.techspacekh.com DocumentRoot /var/www/cacti ErrorLog "/var/log/httpd/cacti.techspacekh.com.log" CustomLog "/var/log/httpd/cacti.techspacekh.com.log" combined Alias /cacti /var/www/cacti <Directory /var/www/cacti/> <IfModule mod_authz_core.c> Require all granted </IfModule> </Directory> </VirtualHost>
Then, we need to restart Apache service.
# systemctl restart httpd
Finally, we are ready to install Cacti application. In your broswer, in the address box type in http://cacti.techspacekh.com and the following windows appears.
You face with the following issue after click next.
To fix this issue, execute the following command.
# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql # mysql -u root -p mysql> use mysql; mysql> grant select on mysql.time_zone_name to cactiuser@localhost; mysql> flush privileges;
At the same time, you also face the following issue.
To fix this issue edit file /etc/my.cnf.d/server.cnf and add the the following lines under [mysql] section.
# vim /etc/my.cnf.d/server.cnf [mysqld] collation-server = utf8_general_ci init-connect='SET NAMES utf8' character-set-server = utf8 max_heap_table_size = 256M max_allowed_packet = 16777216 tmp_table_size = 64M join_buffer_size = 64M innodb_file_per_table = on innodb_doublewrite = off innodb_additional_mem_pool_size = 80M innodb_flush_log_at_trx_commit = 2 innodb_buffer_pool_size = 338M
Then, we need to restart MariaDB database service.
# systemctl restart mariadb
Do not forget to check all of the following graph templates.
Now we have come to end of installing Cacti application.
The default user and password is admin/admin and it will force you to change the password after the first login.
Go to Console and then Devices. Select “Place on a Tree (Default Tree)” option and then click Go.
Click on “Local Linux Machine”, under General Device Options section, change the value in Hostname box from localhost to the IP address of the Cacti server.
Under SNMP Options section, choose the option “Version 2” from the drop-down list of SNMP Version.
Under Availability/Reachability Options section, choose the option “SNMP Uptime” from the drop-down list of Downed Device Detection.
Finally, click save at the bottom of of the and you should see the following on the top of the page.
Go to Console and then Settings. On Poller Intervall, select “Every Minute”, on Cron interval select “Every Minute” and then click save.
On the Graphs tab you should see something as the following now.
That’s all about installing Cacti web-based application for network nonitoring on RHEL/CentOS 7 from Tech Space KH. Hopefully, you can find this guide informative. If you have any questions or suggestions you can always leave your comments below. I will try all of my best to review and reply them.