This guide will cover how to install and configure Cacti on RHEL 8 / CentOS 8. Monitoring is a key component of any Infrastructure. At ComputingPost, so far, we have covered the usage of Zabbix, telegraf/ Influxdb, Grafana, and Prometheus. Cacti is a completely open-source network monitoring and graphing tool that was designed as a front-end application for the industry-standard data logging tool – RRDtool.
Cacti harnesses the power of RRDTool’s data storage and graphing functionality. Some good features of Cacti include:
- Fast polling of metrics
- Support for multiple data acquisition methods
- Support for advanced graph templating
- User management functionality with ACL
Cacti provides an intuitive and easy to use web interface for managing network monitoring and configurations. There are dependencies needed for building and running Cacti on RHEL 8 / CentOS 8. This section will cover installation and configuration of each component.
Step 1: Install Build tools and System Dependencies
Upgrade your OS:
sudo dnf -y update
sudo reboot
Start with installation of Development Tools set.
After installation of Development tools, install SNMP packages.
sudo dnf install -y net-snmp net-snmp-utils rrdtool
Step 2: Install php and required extensions
Install PHP and extensions required by Cacti on your RHEL / CentOS 8.
sudo dnf -y install @php
sudo dnf -y install php php-mysqlnd,curl,gd,intl,pear,recode,ldap,xmlrpc,snmp,mbstring,gettext,gmp,json,xml,common
Verify PHP version and loaded modules.
$ php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Set PHP Paramenets inside /etc/php.ini
file.
sudo vim /etc/php.ini
Set correct timezone:
date.timezone = Africa/Nairobi
Change PHP memory limit to 400M
memory_limit = 512M
Update Maximum execution time of each script:
max_execution_time = 300
Start php-fpm
service.
sudo systemctl enable --now php-fpm
Confirm status.
$ systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-03-17 10:23:52 EAT; 5s ago
Main PID: 31139 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 11510)
Memory: 38.2M
CGroup: /system.slice/php-fpm.service
├─31139 php-fpm: master process (/etc/php-fpm.conf)
├─31140 php-fpm: pool www
├─31141 php-fpm: pool www
├─31142 php-fpm: pool www
├─31143 php-fpm: pool www
└─31144 php-fpm: pool www
Mar 17 10:23:52 rhel8.local systemd[1]: Starting The PHP FastCGI Process Manager…
Mar 17 10:23:52 rhel8.local systemd[1]: Started The PHP FastCGI Process Manager.
Step 3: Install Apache Web server
Use the command below to install Apache httpd server.
sudo dnf -y install @httpd
Start and enable service to start at boot.
sudo systemctl enable --now httpd
Status should indicate running.
$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Sun 2019-03-17 10:49:20 EAT; 2s ago
Docs: man:httpd.service(8)
Main PID: 32106 (httpd)
Status: "Started, listening on: port 443, port 80"
Tasks: 213 (limit: 11510)
Memory: 29.2M
CGroup: /system.slice/httpd.service
├─32106 /usr/sbin/httpd -DFOREGROUND
├─32108 /usr/sbin/httpd -DFOREGROUND
├─32109 /usr/sbin/httpd -DFOREGROUND
├─32110 /usr/sbin/httpd -DFOREGROUND
└─32111 /usr/sbin/httpd -DFOREGROUND
Mar 17 10:49:20 rhel8.local systemd[1]: Starting The Apache HTTP Server…
Mar 17 10:49:20 rhel8.local httpd[32106]: Server configured, listening on: port 443, port 80
Mar 17 10:49:20 rhel8.local systemd[1]: Started The Apache HTTP Server.
Allow http and https ports on the firewall.
sudo firewall-cmd --add-service=http,https --permanent
sudo firewall-cmd --reload
Ref: How to Install Apache with mod_ssl & mod_http2 on RHEL 8
Step 4: Install and Configure Database Server
You can choose to use MySQL or MariaDB database server. if you don’t have either installed, below guides should be helpful.
sudo dnf -y install @mariadb
Start and enable mariadb service:
sudo systemctl enable --now mariadb
Secure your database server:
sudo mysql_secure_installation
Reference:
After Database server installation, create database and user for Cacti Monitoring tool.
$ sudo mysql -u root -p
CREATE DATABASE cacti;
GRANT ALL ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY 'StrongDBPassword';
FLUSH PRIVILEGES;
exit
Tune MariaDB database for Cacti
Add the following settings under [mysqld] setion the file /etc/my.cnf.d/mariadb-server.cnf
sudo vim /etc/my.cnf.d/mariadb-server.cnf
Add the following settings inside mysqld section:
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_heap_table_size=128M
tmp_table_size=128M
join_buffer_size=256M
innodb_buffer_pool_size=512M
innodb_doublewrite=OFF
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16
innodb_buffer_pool_instances=5
Restart mariadb service after adding the lines.
sudo systemctl restart mariadb
Step 5: Download and Configure Cacti
Download the latest release of Cacti tarball to your system.
mkdir cacti && cd cacti
curl -SL https://www.cacti.net/downloads/cacti-latest.tar.gz | tar --strip 1 -xzf -
Move cacti folder to /var/www/html
directory.
cd ..
sudo mv cacti/ /var/www/html/
Import Cacti database data
sudo mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
Setup mysql timezone for cacti database user.
mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root -p mysql
Grant cacti MySQL database user access to Timezone database:
$ sudo mysql -u root -p
GRANT SELECT ON mysql.time_zone_name TO [email protected];
ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
FLUSH PRIVILEGES;
QUIT
Configure SELinux.
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti(/.*)?"
sudo restorecon -Rv /var/www/html/cacti
You need to restart apache service after making above modifications,
sudo systemctl restart httpd php-fpm
Configure Cacti
Edit the file /var/www/html/cacti/include/config.php
and set database connection parameters.
$ sudo vi /var/www/html/cacti/include/config.php
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'StrongDBPassword';
$database_port = '3306';
.............
Replace StrongDBPassword
with your cacti user database password. When done. save file and exit.
Create Cacti system log file.
sudo touch /var/www/html/cacti/log/cacti.log
Set directory permissions
sudo chown -R apache:apache /var/www/html/cacti
Setup Cacti cron job.
sudo crontab -u apache -e
Add below.
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
Step 6: Access Cacti installation wizard
Access Cacti Installation Wizard interface on http://[ServerIP/Hostname]/cacti
.
The default Logins are:
- Username: admin
- Password: admin
Change password on the next screen.
The new password should:
- Contain at least 1 numerical character!
- Contain at least 1 special character!
Accept GPL License Agreement and click “Begin“
All pre-installation checks should show green – passed.
Select type of installation in the next window.
Ensure that Directory Permission Checks are Okay.
Confirm that all binaries all located and click Next.
Select default data source profile for polling sources.
Select Device templates to be used after installation.
Confirm database settings are okay.
Confirm installation.
Installation should start, wait for it to finish then access cacti administration web dashboard.
Step 7: Monitor Linux Servers with Cacti
Start and enable snmpd
daemon to start at boot.
sudo systemctl enable --now snmpd
Confirm it is running.
$ systemctl status snmpd
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-03-17 12:24:50 EAT; 4s ago
Main PID: 3129 (snmpd)
Tasks: 1 (limit: 11510)
Memory: 4.9M
CGroup: /system.slice/snmpd.service
└─3129 /usr/sbin/snmpd -LS0-6d -f
Mar 17 12:24:49 rhel8.local systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon….
Mar 17 12:24:50 rhel8.local snmpd[3129]: NET-SNMP version 5.8
Mar 17 12:24:50 rhel8.local systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..
Add the Linux server for monitoring. Login to Cacti as admin user and go to:
Console > Create > New Device
Provide Server details and save the configuration.