How to Setup Cacti Monitoring Tool on Ubuntu 22.04

Introduction

Cacti is an open-source network and server monitoring tool that collects performance data and displays it in easy-to-read graphs.
It is very useful for monitoring system performance over time, such as CPU load, memory usage, disk space, and network traffic.
Cacti is web-based and uses RRDTool to store and graph data.

Why Use Cacti?

  • Graph-based monitoring: Cacti shows metrics in visual graphs, easy to understand.
  • Centralized monitoring: Collects data from multiple servers in one place.
  • SNMP support: Can monitor network devices like switches, routers, and firewalls.
  • Historical data: Store and analyze performance data over time.
  • Open-source: Free and widely used in enterprises.

What Can We Monitor with Cacti?

  • CPU usage
  • Memory usage
  • Disk usage
  • Network bandwidth
  • SNMP-enabled devices (Switches, Routers, Firewalls)
  • Services like Apache, MySQL, and more (with plugins)

Step 1: Update System

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Packages

Cacti requires Apache, PHP, MySQL/MariaDB, SNMP, and RRDTool.

sudo apt install -y apache2 mariadb-server php php-mysql libapache2-mod-php \
  php-snmp php-ldap php-gd php-xml php-mbstring snmp snmpd rrdtool cacti

Step 3: Configure Database for Cacti

Secure MariaDB and create Cacti database:

sudo mysql_secure_installation
sudo mysql -u root -p

Inside MySQL:

CREATE DATABASE cacti;
CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'StrongPassword123';
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 4: Import Cacti Database

sudo mysql -u cactiuser -p cacti < /usr/share/doc/cacti/cacti.sql

Step 5: Configure Cacti Database Connection

Edit /usr/share/cacti/site/include/config.php:

$database_type     = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "StrongPassword123";

Step 6: Configure Apache for Cacti

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

Add:

Alias /cacti /usr/share/cacti/site
<Directory /usr/share/cacti/site>
    Options +FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Enable required modules:

sudo a2enconf cacti
sudo a2enmod php*
sudo systemctl restart apache2

Step 7: Configure SNMP

Edit /etc/snmp/snmpd.conf and set:

agentAddress udp:161,udp6:[::1]:161
rocommunity public

Restart SNMP service:

sudo systemctl restart snmpd

Step 8: Access Cacti Web Interface

Open browser:

http://your-server-ip/cacti

Login using default credentials:

  • Username: admin
  • Password: admin (you will be asked to change it)

Step 9: Add Devices to Monitor

From Cacti web UI → Console → Devices → Add.
Enter server IP and SNMP community (default: public).
Now Cacti will start collecting metrics.

Step 10: View Graphs

Go to Graphs tab → You will see CPU, Memory, Disk, and Network graphs for your server.
You can also create custom graphs and dashboards.

Tips & Tricks for Students

  • Always secure the SNMP community string (avoid default public).
  • Use strong MySQL passwords.
  • Enable Cacti plugins for monitoring services like Apache/MySQL.
  • Check logs at /var/log/apache2/error.log and /var/log/cacti/ if issues occur.
  • Set up cron job for poller: sudo nano /etc/cron.d/cacti

Common Interview Questions

  • Q: What is Cacti used for?
    A: Monitoring servers, network devices, and services using graphs.
  • Q: Which tool does Cacti use for graphing?
    A: RRDTool.
  • Q: Can Cacti monitor network switches?
    A: Yes, using SNMP.
  • Q: Where do you configure database settings for Cacti?
    A: In /usr/share/cacti/site/include/config.php.

Conclusion

We have successfully set up Cacti Monitoring Tool on Ubuntu 22.04.
Cacti helps monitor CPU, memory, disk, network, and SNMP devices with easy-to-read graphs.
This is a great monitoring tool for Linux administrators and is widely used in traditional IT environments.

Leave a Reply

Your email address will not be published. Required fields are marked *