Linux

How to Monitor Your Network with Cacti on Ubuntu

How to Monitor Your Network with Cacti on Ubuntu

Network monitoring is an essential aspect of managing an IT infrastructure. It helps in identifying issues, optimizing performance, and ensuring that resources are utilized efficiently. Cacti, a powerful and open-source network monitoring tool, provides a user-friendly interface for visualizing network data and performance. This article will guide you through the steps to install and configure Cacti on Ubuntu, enabling you to monitor your network effectively.

What is Cacti?
Cacti is a front-end application for the RRDtool, which stores and displays time-series data in a graphical format. It is particularly effective for monitoring network devices, servers, and applications. Cacti allows users to create custom graphs, manage multiple hosts, and schedule data collection.

  • Prerequisites
    Before you begin the installation, ensure that you have the following:

 

  • A server running Ubuntu (18.04 or later is recommended).
  • Root or sudo access to the server.
  • A LAMP stack (Linux, Apache, MySQL, PHP) installed.
  • You can install the LAMP stack by running:

sudo apt update
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-pear php-dev php-gd

  • Step 1: Install Cacti
    Once the prerequisites are in place, you can proceed with the Cacti installation. Cacti is available in the default Ubuntu repository, so installing it is straightforward:

sudo apt install cacti

During the installation, you will be prompted to configure the database for Cacti. Select “Yes” when asked if you want to configure the database. You will need to provide your MySQL root password and create a Cacti database.

Create Cacti Database
Log into MySQL:

sudo mysql -u root -p

  • Then, run the following commands to create a database and user for Cacti:

CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO ‘cactiuser’@’localhost’ IDENTIFIED BY ‘your_password’;
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_password’ with a strong password of your choice.

Import the Default Cacti Data
Next, import the default data to set up Cacti:

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

  • Step 2: Configure Cacti
    After the installation is complete, you need to configure Cacti. Open the Cacti configuration file:

sudo nano /etc/cacti/cacti.conf

  • Update the following lines to match your database settings:

$database_type = “mysql”;
$database_default = “cacti”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “your_password”;

Save and exit the file.

Configure Apache
Cacti needs to be accessible through the web server. Create a new configuration file for Cacti in Apache:

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

Add the following configuration:

Alias /cacti /usr/share/cacti

Options +Indexes
AllowOverride All
Require all granted

Require all granted

  • Enable the Cacti site and the Apache rewrite module:

sudo a2ensite cacti
sudo a2enmod rewrite

  • Restart Apache for the changes to take effect:

sudo systemctl restart apache2

Step 3: Access the Cacti Web Interface
Open a web browser and navigate to http://your_server_ip/cacti. You will see the Cacti web installation wizard. Follow the on-screen instructions to complete the installation.

During the installation, you will be prompted to enter the username and password. The default username is admin, and the password is also admin. You will be required to change the password upon the first login.

Step 4: Add Network Devices
After logging into Cacti, you can start adding network devices for monitoring. To do this, go to Devices > Add Device. Fill in the required details, including the hostname or IP address of the device you want to monitor.

You can also specify the SNMP version and community string if your device supports SNMP. Cacti will poll the devices and gather data based on the settings you configure.

Create Graphs
Once your devices are added, Cacti will automatically create default graphs based on the metrics available for those devices. You can customize these graphs by going to Graphs > Add Graphs. Select the device and choose the data you wish to visualize.

Step 5: Schedule Data Collection
To ensure Cacti collects data regularly, you need to set up a cron job. Open the crontab editor:

sudo crontab -e

  • Add the following line to the file:

*/5 * * * * /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

This cron job will run the poller every five minutes, collecting data from the configured devices.

We appreciate your visit to our page! If you’re interested in exploring more articles about Linux systems and Foreman, feel free to check out the links below.

How to Install and Use Foreman for Infrastructure Management

 Cacti Official Page

Cacti Download page

Related Articles

Leave a Reply

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

Back to top button