FedoraRHEL Based

How To Install Cacti on Fedora 42

Install Cacti on Fedora 42

Cacti stands as one of the most powerful open-source network monitoring and graphing tools available for Linux systems today. As a frontend to RRDTool, Cacti provides system administrators with robust capabilities to monitor network devices, servers, and applications through an intuitive web interface. This guide offers a detailed walkthrough for installing Cacti on Fedora 42, equipping you with everything you need to set up an effective monitoring solution for your IT infrastructure.

Understanding Cacti and Its Requirements

Cacti functions as a comprehensive network monitoring solution that offers extensive graphical representation of network data. At its core, Cacti serves as a frontend to RRDTool (Round Robin Database Tool), storing all necessary information to create graphs and populate them with data in a MySQL/MariaDB database. By leveraging the SNMP (Simple Network Management Protocol), Cacti can effectively monitor various network devices including routers, switches, and servers.

Before proceeding with the installation, ensure your Fedora 42 system meets these requirements:

  • RRDTool 1.5 or higher
  • MySQL/MariaDB 5.1 or greater
  • PHP 5.3 or higher (latest stable version recommended)
  • Web server with PHP support (Apache preferred)
  • SNMP tools for effective network monitoring

Cacti’s extensible architecture allows for functionality expansion through plugins, making it an ideal solution for organizations of all sizes seeking comprehensive network visibility without substantial investment in proprietary solutions.

Preparing Your Fedora 42 System

Proper preparation of your system is crucial for a successful Cacti installation. Follow these steps to ensure your Fedora 42 environment is ready:

Update System Packages

Begin by updating all system packages to ensure you have the latest versions and security patches:

dnf update -y

Install Development Tools

Install the necessary development tools that will support Cacti’s requirements:

dnf groupinstall "Development Tools" -y

Install Required Dependencies

Next, install the SNMP utilities and RRDTool which are essential for Cacti’s functionality:

dnf install -y net-snmp net-snmp-utils rrdtool -y

These preliminary steps lay the groundwork for a smooth Cacti installation process on your Fedora 42 system.

Installation Methods Overview

When installing Cacti on Fedora 42, you have two primary methods to choose from:

Using DNF with COPR Repository

The recommended approach for Fedora 42 users involves utilizing the COPR repository, which simplifies the installation process by handling dependencies automatically. This method provides a more streamlined experience with packages specifically optimized for Fedora systems.

Manual Installation from Source

Alternatively, you can install Cacti manually from source code. While this approach provides greater control over the installation process, it requires more technical knowledge and manual configuration of dependencies.

For most Fedora 42 users, the COPR repository method balances ease of installation with proper system integration, making it the preferred choice for deploying Cacti in production environments.

Method 1: Installing Cacti Using COPR Repository

Using the COPR repository provides a streamlined approach to installing Cacti on Fedora 42. Follow these steps:

1. First, add the nucleo/cacti COPR repository to your system:

dnf copr enable nucleo/cacti

2. Install Cacti and Cacti-spine packages:

dnf install cacti cacti-spine -y

3. Verify the installation by checking the installed packages:

rpm -qa | grep cacti

This method automatically handles dependencies and creates the necessary directory structure for Cacti. The package integration ensures that Cacti fits seamlessly into your Fedora 42 system, with proper file permissions and system paths configured according to best practices.

Method 2: Installing Required Dependencies Manually

If you prefer a manual installation approach, you’ll need to install all dependencies individually. This method gives you more control over the components:

Install Development Tools

dnf groupinstall "Development Tools" -y

Set Up SNMP Utilities

SNMP tools are essential for network device monitoring:

dnf install -y net-snmp net-snmp-utils

Install RRDTool and Related Packages

RRDTool is a critical component for Cacti’s graphing capabilities:

dnf install -y rrdtool rrdtool-devel

Configure Development Libraries

Install other development libraries needed for optimal functionality:

dnf install -y cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel

After installing these dependencies, verify that all requirements are met before proceeding with the Cacti installation process.

Setting Up Web Server and PHP

Cacti requires a properly configured web server and PHP environment. Follow these steps to set up Apache and PHP on your Fedora 42 system:

Install Apache Web Server

dnf install httpd -y
systemctl enable --now httpd

Install PHP and Required Modules

Cacti requires several PHP extensions to function correctly:

dnf install -y php php-{mysqlnd,curl,gd,intl,pear,ldap,xmlrpc,snmp,mbstring,gettext,gmp,json,xml,common}

Configure PHP Settings

Edit the PHP configuration file to optimize it for Cacti:

nano /etc/php.ini

Update the following settings to improve performance and compatibility:

date.timezone = UTC
memory_limit = 512M
max_execution_time = 300

After making these changes, enable and start the PHP-FPM service:

systemctl enable --now php-fpm

These settings ensure that PHP has sufficient resources and correct configuration to handle Cacti’s requirements effectively.

Installing and Configuring MariaDB

A properly configured database is essential for Cacti. Follow these steps to install and configure MariaDB on Fedora 42:

Install MariaDB Server

dnf install mariadb-server -y
systemctl enable --now mariadb

Secure Your MariaDB Installation

mysql_secure_installation

During this process, you’ll set a root password and remove test databases and anonymous users.

Create the Cacti Database

Access the MariaDB shell and create a database for Cacti:

mysql

Once logged in, execute these commands:

CREATE DATABASE cacti;
GRANT ALL ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;

Optimize MariaDB Configuration

Edit the MariaDB configuration file to optimize database performance for Cacti:

nano /etc/my.cnf.d/mariadb-server.cnf

Add these performance-enhancing settings under the [mysqld] section:

character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_heap_table_size=128M
tmp_table_size=128M
join_buffer_size=128M
innodb_buffer_pool_size=1024M
innodb_doublewrite=ON
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16
innodb_buffer_pool_instances=10
innodb_io_capacity=5000
innodb_io_capacity_max=10000

Restart MariaDB to apply these changes:

systemctl restart mariadb

These optimizations significantly improve Cacti’s performance when dealing with large amounts of monitoring data.

Installing Cacti (Manual Method)

If you’ve chosen the manual installation method, follow these steps to install Cacti from source:

Download Cacti

Navigate to your web server directory and download the latest Cacti release:

cd /var/www/html/
wget --no-check-certificate https://www.cacti.net/downloads/cacti-latest.tar.gz

Extract and Configure

Extract the downloaded files and set up the directory structure:

tar -xvzf cacti-latest.tar.gz
mv cacti-1.2.24 cacti

Import the Database Schema

Import the Cacti database schema to set up the required tables:

cd cacti
mysql -u root -p cacti < /var/www/html/cacti/cacti.sql

Import Timezone Information

Import timezone data to ensure accurate time-based graphing:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

Configure Database Character Set

Login to MariaDB and set the proper character encoding:

mysql
GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
FLUSH PRIVILEGES;
EXIT;

Set Up Cacti Configuration File

Copy and edit the Cacti configuration file:

cp /var/www/html/cacti/include/config.php.dist /var/www/html/cacti/include/config.php
nano /var/www/html/cacti/include/config.php

Update the database settings:

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

Create Log File and Set Permissions

touch /var/www/html/cacti/log/cacti.log
chown -R apache:apache /var/www/html/cacti

These steps establish a functional Cacti installation from source code, giving you full control over the configuration and file locations.

Configuring Apache for Cacti

Proper web server configuration is essential for accessing the Cacti interface. Follow these steps to configure Apache for Cacti:

Create a Dedicated Configuration File

sudo vi /etc/httpd/conf.d/cacti.conf

Add the following configuration to the file:

Alias /cacti /usr/share/cacti

<Directory /usr/share/cacti/>
    Options +FollowSymLinks
    AllowOverride None
    <IfModule mod_authz_core.c>
        # Apache 2.4
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Deny,Allow
        Deny from all
        Allow from all
    </IfModule>
</Directory>

Save and close the file.

Restart Apache to Apply Changes

systemctl restart httpd

This configuration creates a dedicated URL path for Cacti and sets the appropriate permissions for web access.

Setting Up the Cron Job for Polling

Cacti requires a scheduled task to collect data from monitored devices. Set up a cron job to automate this process:

Create the Cron Job File

nano /etc/cron.d/cacti

Add the following line to run the poller every 5 minutes:

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

Set Proper Permissions

chmod 644 /etc/cron.d/cacti

Verify the Poller Operation

Check if the poller is running correctly:

tail -f /var/log/cacti/cacti.log

This cron job ensures that Cacti consistently collects and updates monitoring data from your network devices.

Installing and Configuring Spine (Optional)

Spine is a faster alternative to the standard cmd.php poller, offering significant performance improvements for larger installations:

Install Spine Package

If using the repository method:

dnf install cacti-spine -y

For manual installation:

wget https://www.cacti.net/downloads/spine/cacti-spine-latest.tar.gz
tar -zxvf cacti-spine-latest.tar.gz
cd cacti-spine-1.2.x
./configure
make
make install

Configure Spine

Edit the spine configuration file:

nano /etc/spine.conf

Update the database settings to match your Cacti configuration:

DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass password
DB_Port 3306

Enable Spine in Cacti Settings

After installing Spine, you can switch from cmd.php to Spine through the Cacti web interface in Settings > Poller.

Spine significantly improves polling performance, especially in environments with many monitored devices, making it a valuable addition to larger Cacti deployments.

Accessing the Cacti Web Interface

After completing the installation and configuration steps, you can access the Cacti web interface:

Configure Firewall

First, ensure your firewall allows access to the web server:

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload

Access Cacti in Web Browser

Open your web browser and navigate to:

http://your_server_ip/cacti

or

http://domain.com/cacti

Initial Login

Use the default credentials for your first login:

  • Username: admin
  • Password: admin

You’ll be prompted to change the default password immediately for security reasons.

Install Cacti on Fedora 42

Accept License Agreement

Review and accept the Cacti license agreement to proceed with the installation wizard.

Completing Web-Based Installation

Follow these steps to complete the web-based installation process:

Pre-Installation Checks

The installation wizard will check your system configuration and suggest any necessary changes to the PHP settings in /etc/php.ini.

Select Installation Type

Choose “New Primary Server” for a standard installation.

Verify Directory Permissions

The installer will check if all required directories have proper permissions.

Confirm Binary Paths

Verify that the installer correctly detected paths to required binaries like PHP and RRDTool.

Select Device Templates

Choose the device templates you want to install based on your monitoring needs.

Finalize Installation

Complete the installation process and click “Get Started” to access your new Cacti installation.

This web-based setup ensures that all components are properly configured and prepares the system for monitoring operations.

Post-Installation Configuration

After completing the installation, follow these steps to set up basic monitoring:

Configure Your First Device

  1. Navigate to Console > Devices
  2. Click “Add” to create a new device
  3. Enter the hostname or IP address
  4. Select the appropriate device template
  5. Configure SNMP settings if required
  6. Click “Create”

Set Up Graphs

  1. After adding a device, select it from the devices list
  2. Click “Create Graphs for this Host”
  3. Select the graphs you want to create
  4. Click “Create”

Adjust System Settings

Review and update these essential settings:

  1. Path Settings: Verify paths to binaries and plugins
  2. Poller Configuration: Adjust polling intervals if needed
  3. Authentication: Configure LDAP or other authentication methods if required
  4. Visual Settings: Customize the appearance to match your preferences

Security Hardening

Implement these security measures:

  1. Change default database passwords
  2. Configure HTTPS for secure access
  3. Implement IP-based access restrictions
  4. Regular system and Cacti updates

These post-installation steps transform your basic Cacti installation into a functional monitoring system tailored to your network environment.

Troubleshooting Common Installation Issues

Even with careful installation, issues may arise. Here are solutions to common problems:

Database Connection Problems

If Cacti cannot connect to the database:

  1. Verify database credentials in Cacti’s config.php file
  2. Ensure MariaDB service is running: systemctl status mariadb
  3. Check database user permissions: SHOW GRANTS FOR 'cacti'@'localhost';

Permission Issues

If you encounter file permission errors:

chown -R apache:apache /usr/share/cacti
chmod -R 755 /usr/share/cacti/rra
chmod -R 755 /usr/share/cacti/log

SNMP Configuration Problems

If SNMP polling fails:

  1. Verify SNMP is installed: rpm -qa | grep snmp
  2. Test SNMP connectivity: snmpwalk -v2c -c public hostname
  3. Check firewall settings for UDP port 161

RRDTool Errors

For RRDTool-related issues:

  1. Verify RRDTool installation: which rrdtool
  2. Check RRDTool version: rrdtool --version
  3. Ensure RRDTool path is correctly configured in Cacti settings

PHP Configuration Issues

If PHP settings are causing problems:

  1. Verify PHP version compatibility: php -v
  2. Check PHP extensions: php -m | grep -E 'snmp|mysql|gd'
  3. Adjust PHP memory limits in php.ini if needed

These troubleshooting steps address the most common issues encountered during Cacti installation and configuration.

Congratulations! You have successfully installed Cacti. Thanks for using this tutorial for installing the Cacti on your Fedora 42 Linux system. For additional help or useful information, we recommend you 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!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button