How to Install Cacti on Rocky Linux 8

Install Cacti on Rocky Linux 8

In this article, we will have explained the necessary steps to install Cacti on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Cacti is an open-source monitoring tool that works as a front end for the enterprise class logging tool, RRDtool. It enables users to view CPU load graphs, RAM usage, and other information collected from different hosts. Like Nagios, Cacti supports SNMP that makes it possible to monitor: Linux’s, BSD’s, and Windows hosts.

Install Cacti on Rocky Linux 8

Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.

sudo dnf install epel-release
sudo dnf update
sudo dnf upgrade

Step 2. Install LAMP on the Rocky Linux system.

You need to set Rocky Linux up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Rocky Linux before you continue.

Step 3. Install SNMP and RRD Tool.

Now we will install SNMP and RRDtool, which are required for gathering and analyzing system metrics:

sudo dnf install -y net-snmp net-snmp-utils net-snmp-libs rrdtool

Once done, start and enable snmpd with the commands:

sudo systemctl start snmpd
sudo systemctl enable snmpd

Step 4. Configure MySQL/MariaDB database.

Create a database and user for cacti and grant all the necessary privileges to the cacti user:

mysql -u root -p

Once you’re in the MySQL console, create a new database:

MariaDB [(none)]> CREATE DATABASE cactidb;
MariaDB [(none)]> GRANT ALL ON cactidb.* TO [your-email] IDENTIFIED  BY 'your-passwd';
MariaDB [(none)]> EXIT;

Then, import the MySQL test data timezone.sql file into the MySQL database:

mysql -u root -p mysql < /usr/share/mariadb/mysql_test_data_timezone.sql

Next, connect to the MySQL database and provide the cacti user access to the mysql.time zone:

MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO [email protected];
MariaDB [(none)]> EXIT;

Now edit the MariaDB configuration file:

nano /etc/my.cnf.d/mariadb-server.cnf

Paste the following line:

# 25% Of Total System Memory
# pool_size/128 for less than 1GB of memory

Step 5. Install Cacti on Rocky Linux system.

We install the Cacti monitoring tool as shown:

sudo dnf install cacti

Verify the installation of Cacti:

rpm -qi cacti

Next, use the following command to import the default database tables:

mysql -u root -p cactidb < /usr/share/doc/cacti/cacti.sql

We need to do some initial configurations for Cacti:

sudo nano /usr/share/cacti/include/config.php

Modify file:

$database_type = 'mysql';
$database_default = 'cactidb';
$database_hostname = 'localhost';
$database_username = 'cacti_user';
$database_password = 'cactidb';
$database_port = '3306';

Then, Make apache user the owner of the Cacti software directory:

sudo chown -R apache:apache /var/www/html/cacti
sudo systemctl restart httpd

Next, set up cron for Cacti by editing the /etc/cron.d/cacti file as shown:

sudo nano /etc/cron.d/cacti

Uncomment the following line to have a Cacti poll for data every 5 minutes:

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

Step 6. Configure Firewall.

Allow HTTP and HTTPS service through the firewall

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Step 7. Access Cacti Web Interface on Rocky Linux 8.

We can now access our cacti web interface for the installation wizard via http://your-server-ip/cacti. The login page shown below will appear. Log in with the default credentials shown:

Username: admin
Password: admin

Install Cacti on Rocky Linux 8

That’s all you need to do to install Cacti on Rocky Linux. I hope you find this quick tip helpful. For further reading on the Cacti, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.