How to Install Cacti on Ubuntu 22.04 – Holhol24

0

Cacti is a free and open-source web-based network monitoring and graphing tool that helps to track your device’s network performance in almost real-time.

Cacti gather performance metrics from servers and network devices and graph and store them for reporting and historical analysis.

Here, we will see how to install Cacti on Ubuntu 22.04.

Prerequisites

First, update the repository index.

sudo apt update

Install Apache & PHP Extensions

sudo apt install -y apache2 libapache2-mod-php php php-mysql php-xml php-mbstring php-json php-gd php-gmp php-zip php-ldap

PHP Settings for Cacti

Cacti require the below values in php.ini files. You may need to update the values for both web services /etc/php/8.1/apache2/php.ini and CLI /etc/php/8.1/cli/php.ini, assuming that your system has PHP v8.1.

date.timezoneUS/Central

memory_limit = 256M

max_execution_time = 60

sudo sed -i 's/\;date.timezone \=/date.timezone \= US\/Central/g' /etc/php/8.1/apache2/php.ini /etc/php/8.1/cli/php.ini

sudo sed -i 's/^memory_limit \= .*/memory_limit \= 512M/g' /etc/php/8.1/apache2/php.ini /etc/php/8.1/cli/php.ini

sudo sed -i 's/^max_execution_time \= .*/max_execution_time \= 60/g' /etc/php/8.1/apache2/php.ini /etc/php/8.1/cli/php.ini

Install MariaDB Database

Next, install the MariaDB database by following the below URL.

READ: How to install MariaDB on Ubuntu 22.04

Tune Database for Cacti

You will need to make a few MariaDB settings for Cacti installation by editing the configuration file.

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add/update the below settings in the [mysqld] section.

collation-server = utf8mb4_unicode_ci
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 128M
innodb_file_format = Barracuda
innodb_doublewrite = off
innodb_large_prefix = 1
innodb_buffer_pool_size = 1024MB
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

Install SNMP for Cacti

sudo apt install -y snmp php-snmp rrdtool librrds-perl

Finally, restart MariaDB and Apache services.

sudo systemctl restart mariadb

sudo systemctl restart apache2

Install Cacti on Ubuntu 22.04

Create Database for Cacti

First, log in to the MariaDB server.

sudo mysql -u root -p

Then, create a database for the Cacti installation.

CREATE DATABASE cacti DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Grant permission to the newly created database.

GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword';

ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

flush privileges;

exit

You will need to allow the database user (cactiuser) to have access to the mysql.time_zone_name table. To do that, first, import the mysql_test_data_timezone.sql to the mysql database.

sudo mysql -u root -p mysql 

Then, log in to MySQL.

sudo mysql -u root -p

Grant the permission to the database user (cactiuser).

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;

flush privileges;

exit

Download Cacti Package

First, download the latest version of the Cacti package using the wget command.

wget https://www.cacti.net/downloads/cacti-latest.tar.gz

Then, extract the Cacti archive using the tar command and move the extracted files to the /var/www/html directory.

tar -zxvf cacti-latest.tar.gz

sudo mv cacti-1* /var/www/html/cacti

And then import the default Cacti database data to the newly created database.

sudo mysql -u root -p cacti 

Next, edit the Cacti config file to specify the database type, name, hostname, user, and password information.

sudo nano /var/www/html/cacti/include/config.php

Then, make the changes according to your requirement.

/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipassword";
$database_port = "3306";
$database_ssl = false;

Finally, restart the Apache service.

sudo systemctl restart apache2

You may also need to change the ownership of the Cacti directory to Apache user (www-data).

sudo chown -R www-data:www-data /var/www/html/cacti

Data Collection Frequency for Cacti

Add the following entry in the cron to allow Cacti poller to poll every five minutes.

echo "*/5 * * * * www-data php /var/www/html/cacti/poller.php > /dev/null 2>&1" | sudo tee /etc/cron.d/cacti

Setup Cacti

Visit the following URL to begin the installation of Cacti.

http://your.ip.add.ress/cacti

Login to Cacti to initiate the setup.

The default username and password are admin.

Cacti Installation

Follow the Cacti web installer to set up Cacti on your system.

  1. First, you must change the admin user’s password before starting the setup. Ensure your password meets the minimum requirement.
  2. Accept the Cacti license agreement and then click Begin to continue.
  3. On the next page, Cacti will perform pre-installation checks. Since we have already configured the system for Cacti, the pre-check should be clean. If Cacti reports any issues, fix them and click the Refresh icon to get the latest pre-check report. Finally, click Next.
  4. Select New Primary Server as an installation type and then click Next.
  5. Cacti perform Directory Permission Checks on this page to report permission issues you may have in Cacti installation directories. If the report is clean, click Next.
  6. Cacti now check for Critical binary locations and versions required for installation. Ensure the report is green and then click Next.
  7. Click the checkbox of I have read this statement on the Input Validation Whitelist Protection page and then click Next.
  8. Update the Network Range if you want to enable network scanning. Also, Cron Interval is Every 5 Minutes as we already configured cron to poll every five minutes.
  9. Click Next on the Template Setup page.
  10. Then, click Next again on the Database Compliant page.
  11. Ensure you click Confirm Installation and then click Install.

In a minute or two, the Cacti installation will be complete. Click on the Get Started to take you directly to the Cacti dashboard.

Cacti Installation Complete How to Install Cacti on Ubuntu 22.04 - Holhol24 How to Install Cacti on Ubuntu 22.04 – Holhol24 svg xml  3Csvg 20xmlns 3D 22http 3A 2F 2Fwww
Cacti Installation Complete

Access Cacti Web Interface

Open up a browser and visit the below URL.

http://your.ip.add.ress/cacti

Login to Cacti using the admin with the password you entered during the Cacti setup.

The Cacti Dashboard will look like the below after your successful login.

You can go to Graphs >> Default Tree >> Local Linux Machine to see the graph of your Cacti server.

System Usage Graph How to Install Cacti on Ubuntu 22.04 - Holhol24 How to Install Cacti on Ubuntu 22.04 – Holhol24 svg xml  3Csvg 20xmlns 3D 22http 3A 2F 2Fwww
System Usage Graph

Conclusion

That’s All. I hope you have learned how to install Cacti on Ubuntu 22.04. Now, the Cacti is ready to monitor remote Linux machines.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More