Thursday 2 November 2023

How to Install Cacti Monitoring Tool on CentOS 8 with LAMP Stack

Cacti is an open source and web-based network monitoring tool and provide graphical diagram of network real time performance. Cacti collect performance data from servers and network devices and store them for reporting and historical analysis with graphs.
This article describes How to Install Cacti Monitoring tool on CentOS 8 with LAMP Stac.
Step 1. Install LAMP Stack: Cacti runs with LAMP Stack or LEMP Stack. So, follow the article How to Install LAMP Stack on CentOS 8 to install http web server, database and PHP.
[root@linuxcnf ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@linuxcnf ~]#
[root@linuxcnf ~]# httpd -v
Server version: Apache/2.4.37 (centos)
Server built:   Nov 12 2021 04:57:27
[root@linuxcnf ~]#
[root@linuxcnf ~]# mysql --version
mysql  Ver 15.1 Distrib 10.3.28-MariaDB, for Linux (x86_64) using readline 5.1 [root@linuxcnf ~]#
[root@linuxcnf ~]# php --version
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
[root@linuxcnf ~]#
Step 2. Install EPEL Repository: Follow the article How to configure EPEL repository on CentOS 8 to install Cacti and related packages.
Step 3. Install Prerequisites: Run the following command to install Cacti prerequisites to gathering and processing system data and metrics:
[root@linuxcnf ~]# dnf install net-snmp net-snmp-utils rrdtool php-{mysqlnd,curl,gd,intl,pear,recode,ldap,xmlrpc,snmp,mbstring,gettext,gmp,json,xml,common}
  cairo-1.15.12-3.el8.x86_64                                                         dejavu-fonts-common-2.35-7.el8.noarch
  dejavu-sans-mono-fonts-2.35-7.el8.noarch                                           fontconfig-2.13.1-4.el8.x86_64
[root@linuxcnf ~]#
Step 4. Install Cacti: Run the following command to install Cacti packages and its binaries. The Cacti packages are available in EPEL repository.
[root@linuxcnf ~]# dnf install cacti -y
Last metadata expiration check: 0:25:41 ago on Sat 28 Oct 2023 08:12:31 AM EDT.
Dependencies resolved.
[root@linuxcnf ~]#
Step 5. Database Configuration: Create database and provide appropriate privileges to store Cacti data:
[root@linuxcnf ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.28-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database cacti;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'SomeP@ssw0rd';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [mysql]> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
Query OK, 0 rows affected (0.000 sec)
MariaDB [mysql]>
MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> quit;
[root@linuxcnf ~]#
Step 6. Database and Web Server Configuration: Now configure database and Apache web server to access Cacti:
Ø  Import the default database into the cacti database:
[root@linuxcnf ~]# mysql cacti < /usr/share/doc/cacti/cacti.sql -u cacti -p
Enter password:
[root@linuxcnf ~]#
 Configure database settings for cacti and make the changes accordingly:

[root@linuxcnf ~]# vi /usr/share/cacti/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 = 'cacti';
$database_password = 'SomeP@ssw0rd';
$database_port     = '3306';
$database_retries  = 5;
$database_ssl      = false;
 Configure Apache Web server to access Cacti application:
[root@linuxcnf ~]# vi /etc/httpd/conf.d/cacti.conf
Alias /cacti    /usr/share/cacti
<Directory /usr/share/cacti/>
        <IfModule mod_authz_core.c>
                # httpd 2.4
                Require all granted
        <IfModule !mod_authz_core.c>
                # httpd 2.2
                Order deny,allow
                Deny from all
                Allow from all
Uncomment the below cron entry to run in every 5 minutes to collect the data:
[root@linuxcnf ~]# vi /etc/cron.d/cacti
[*/5 * * * *     apache  /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
Step 7. Restart Web Service: Run the following command to restart httpd service to reflect the configuration changes:
[root@linuxcnf ~]# systemctl restart httpd
[root@linuxcnf ~]#
Step 8. Cacti Web Interface Configuration: Follow the below steps to complete the Cacti initial setup:
Open any browser and access cacti server server http://Server-IP/ and use below credentials:
Username: admin
Password: admin

Change password in after fist login as shown below:

Accept liance agreement and click on next button for next installation step:

Next screen showing prechecks for Cacti installation as bellow. Check all the prechecks carefully and change the configuration accordingly:

Change the below setting mandatory setting as below:
[root@linuxcnf ~]# vi /etc/php.ini
memory_limit = 512M
max_execution_time = 60
date.timezone = Asia/Kolkata
All prechecks are done as per recommendations as shown below. Now click on next for further installation:

Select New Primary Server installation and click on next and make sure all permissions are correct as recommended and click on next:

 The below screen will show if any missing packages or configuration. Once checked click on next:

Choose default configuration as the it will auto detect the recommended settings:

Choose the devices template for auto installation as per environment and click on next:

Below screen will show recommended settings for database so change the configuration as below and restart MySQL database service:

[root@linuxcnf ~]# vi /etc/my.cnf.d/mariadb-server.cnf
MariaDB [(none)]> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.001 sec)
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]>
Now recommended settings are done for data base as shown below. Click on next button for next screen:

Check on the installation confirmation and click on Install button:

Screen will show as below once the installation completed:

Click on Get Started button to go on Admin Console and use admin credentials to login. The admin console will show as below:

Done!!! Cacti installation is completed now on CentOS 8.

No comments:

Post a Comment