LinuxTutorialsUbuntu

How To Install Cacti Monitoring on Ubuntu 20.04 LTS

Install Cacti Monitoring on Ubuntu 20.04

In this tutorial, we will show you how to install Cacti Monitoring on Ubuntu 20.04 LTS. For those of you who didn’t know, Cacti is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-source, industry-standard data logging tool RRDtool. It is used to get CPU load and network bandwidth utilization in a graph format.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Cacti Monitoring on a Ubuntu 18.04 LTS Focal Fossa server.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, you can harm your system if you’re not careful when acting as the root.

Install Cacti Monitoring on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Install the LAMP server.

A Ubuntu 20.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here.

Step 3. Configuring MariaDB for Cacti.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next, we will need to log in to the MariaDB console and create a database for the Cacti. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Cacti installation:

create database cacti;
grant all privileges on cacti.* to idroot@localhost identified by 'your-password';
flush privileges;
quit;
sudo mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

After that, log in to MariaDB:

mysql -u root -p

Grant the permission to “idroot” user:

GRANT SELECT ON mysql.time_zone_name TO idroot@localhost;
flush privileges;
exit

Step 4. Installing Cacti on Ubuntu 20.04.

Now we, run the below command to get install the SNMP and rrdtool for the monitoring of devices.

sudo apt install snmp php-snmp rrdtool librrds-perl

Next, download the latest version of the Cacti using the wget command:

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

After the download is finished extract the downloaded package:

sudo tar zxvf cacti-latest.tar.gz
cd cacti-1.2.16/
sudo mv * /var/www/html/
sudo mysql -u root -p cacti < /var/www/html/cacti.sql

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

sudo nano /var/www/html/include/config.php
/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "idroot";
$database_password = "your-password";
$database_port = "3306";
$database_ssl = false;
sudo touch /var/www/html/log/cacti.log
sudo chown -R www-data:www-data /var/www/html/*

Step 5. Configure Apache web server for Cacti.

Create a new config file with the name cacti.conf in the “/etc/apache2/sites-enabled”:

sudo nano /etc/apache2/sites-enabled/cacti.conf

Use the following configuration:

Alias /cacti /var/www/html

  <Directory /var/www/html>
      Options +FollowSymLinks
      AllowOverride None
      <IfVersion >= 2.3>
      Require all granted
      </IfVersion>
      <IfVersion < 2.3>
      Order Allow,Deny
      Allow from all
      </IfVersion>

   AddType application/x-httpd-php .php

<IfModule mod_php.c>
      php_flag magic_quotes_gpc Off
      php_flag short_open_tag On
      php_flag register_globals Off
      php_flag register_argc_argv On
      php_flag track_vars On
      # this setting is necessary for some locales
      php_value mbstring.func_overload 0
      php_value include_path .
 </IfModule>

  DirectoryIndex index.php
</Directory>

Finally, restart the apache server to take effects:

sudo a2ensite cacti
sudo systemctl restart apache2

Step 6. Accessing Cacti Web Interface.

Cacti will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://your-domain.com or http://server-ip-address and complete the required steps to finish the installation. You will get the “Cacti Installation Guide” on the screen. Login with username: admin and password: admin and cacti force you to change the default password.

Install Cacti Monitoring on Ubuntu 20.04

Congratulations! You have successfully installed Cacti. Thanks for using this tutorial for installing Cacti Monitoring on Ubuntu 20.04 Focal Fossa system. For additional help or useful information, we recommend you to check the official Cacti website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

Save

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button