How to Install & Configure Cacti Monitoring tool on ubuntu 20.04.

Cacti is a free & open source monitoring tool.It is web-based network monitoring tool & written in PHP language.Cacti monitoring tool uses SNMP protocol to monitor network traffic & bandwidth utilization.We have to monitor CPU utilization and network bandwidth utilization in a graph format.

Install Cacti on ubuntu

Update the system.

apt-get update

Install Apache2 & PHP with modules.

apt-get install apache2 php php-mysql libapache2-mod-php
&
apt-get install php-xml php-ldap php-mbstring php-gd php-gmp

Install SNMP and RRDtool.

apt-get install snmp php-snmp rrdtool librrds-perl

Configure the php.ini.

vim /etc/php/7.4/apache2/php.ini

Add the given below lines:

memory_limit = 512M
max_execution_time = 60
date.timezone = Asia/Kolkata

Same configuration in /etc/php/7.4/cli/php.ini file.

vim /etc/php/7.4/cli/php.ini

Add the given below lines:

memory_limit = 512M
max_execution_time = 60
date.timezone = Asia/Kolkata

Restart the apache2 service.

systemctl restart apache2

Install Mariadb server & Client.

apt-get install mariadb-server mariadb-client

Configure the MariaDB default file.

vim /etc/mysql/mariadb.conf.d/50-server.cnf

Add/check the given below lines:

collation-server = utf8mb4_unicode_ci
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 512M
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

Restart the MariaDB service.

systemctl restart mariadb

Login to mariadb server.

mysql -u root -p

Press Enter.

Create a database.

create database database-name;
or
create database cactidb;

Run the following command.

GRANT ALL ON cactidb.* TO [email protected] IDENTIFIED BY 'password';
&
flush privileges;
&
exit

Import the mysql_test_data_timezone.sql to mysql database.

mysql mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Again Login to mariadb server.

mysql -u root -p

Run the following command.

GRANT SELECT ON mysql.time_zone_name TO [email protected];
flush privileges;
exit;

Download Cacti.

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

Extract the downloaded file.

tar -zxvf cacti-latest.tar.gz

Move the extracted file to /var/www/html (apache root directory).

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

Import the database to the cactidb.

mysql cactidb < /var/www/html/cacti/cacti.sql

Configure the Cacti config.php file

vim /var/www/html/cacti/include/config.php

Change the given below lines:

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

Create a Cacti log file.

touch /var/www/html/cacti/log/cacti.log

Give the following permissions.

chown -R www-data:www-data /var/www/html/cacti/
chmod -R 775 /var/www/html/cacti/

Create a Cacti cron job file.

*/5 * * * * www-data php /var/www/html/cacti/poller.php > /dev/null 2>&1

Configure the apache file for Cacti.

vim /etc/apache2/sites-available/cacti.conf

Add the given below lines:

Alias /cacti /var/www/html/cacti

  <Directory /var/www/html/cacti>
      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>

Enable the config file.

a2ensite cacti.conf

Restart the Apache service.

systemctl restart apache2

Open Cacti Web Interface

http://server-ip/cacti

Here is the output.

Provide the user-name & password.By default,admin is user-name & password.

 

Fig 1

 

  • Change the password.

 

Fig 2

 

  • Accept the License.
  • Click on Begin.

 

Fig. 3

 

  • Check the Pre-installation packages.
  • Click on Next.

 

Fig. 5

 

  • Click on Next.

 

Fig. 6

 

  • Check the Directory Permission.
  • Click on Next.

 

Fig. 7

 

  • Click on Next.

 

Fig 1

 

  • Click on Checkbox “i have read this statement”.
  • Click on Next.

 

Fig 2

 

  • Check Default Profile.
  • Click on Next.

 

Fig. 3

 

  • Click on Next.

 

Fig. 4

 

  • Click on Confirm Installation checkbox.
  • Click on Install.

 

Fig 2

 

  • Installation is started.

 

Fig. 5

 

  • After sometimes Cacti is Ready.

 

Fig. 4

 

Leave a Reply

Your email address will not be published.