How To Install Cacti on openSUSE
In today’s interconnected world, network monitoring has become an essential aspect of maintaining a robust and efficient IT infrastructure. Cacti, an open-source network monitoring and graphing tool, has emerged as a popular choice for system administrators and network engineers. This article will guide you through the process of installing Cacti on openSUSE, a powerful and flexible Linux distribution.
Cacti provides a user-friendly interface for creating and managing graphs of network data, allowing you to visualize performance metrics and identify potential issues before they become critical. By leveraging the stability and security of openSUSE, you can create a reliable monitoring solution that scales with your network’s growth.
Prerequisites
Before we dive into the installation process, let’s ensure you have everything needed to successfully set up Cacti on your openSUSE system:
- A clean installation of openSUSE Leap (15.2 or later) or Tumbleweed
- Root access or sudo privileges on your openSUSE system
- A stable internet connection for downloading packages
- At least 2GB of RAM and 20GB of free disk space
- Basic familiarity with Linux command-line operations
It’s important to note that while these requirements are minimal, your specific needs may vary depending on the size of your network and the number of devices you plan to monitor.
Preparing the System
To ensure a smooth installation process, we’ll start by updating your openSUSE system and installing necessary dependencies.
Updating openSUSE
Open a terminal and run the following commands:
sudo zypper refresh
sudo zypper update
This will update your package lists and upgrade all installed packages to their latest versions.
Installing Necessary Dependencies
Next, install the required packages for Cacti:
sudo zypper install wget net-snmp net-snmp-utils rrdtool
Configuring Firewall Settings
If you have the firewall enabled, you’ll need to open the necessary ports for Cacti to function properly. Run the following commands:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Installing LAMP Stack
Cacti requires a web server, database, and PHP to function. We’ll install the LAMP (Linux, Apache, MySQL, PHP) stack to meet these requirements.
Apache Web Server Installation
Install Apache with the following command:
sudo zypper install apache2
Start and enable Apache to run at boot:
sudo systemctl start apache2
sudo systemctl enable apache2
MySQL/MariaDB Database Setup
Install MariaDB, which is a drop-in replacement for MySQL:
sudo zypper install mariadb mariadb-tools
Start and secure the MariaDB installation:
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
Follow the prompts to set a root password and secure your MariaDB installation.
PHP Installation and Configuration
Install PHP and necessary modules:
sudo zypper install php7 php7-mysql apache2-mod_php7 php7-gd php7-snmp php7-mbstring php7-curl php7-ldap php7-gmp php7-zip php7-zlib
Edit the PHP configuration file:
sudo nano /etc/php7/apache2/php.ini
Modify the following values:
memory_limit = 512M
max_execution_time = 60
date.timezone = Your/Timezone
Save the file and restart Apache:
sudo systemctl restart apache2
Installing and Configuring Cacti
Now that we have our LAMP stack ready, let’s proceed with installing Cacti.
Downloading Cacti
Download the latest version of Cacti:
cd /tmp
wget https://www.cacti.net/downloads/cacti-latest.tar.gz
tar -zxvf cacti-latest.tar.gz
sudo mv cacti-* /var/www/html/cacti
Creating Cacti Database
Create a database and user for Cacti:
sudo mysql -u root -p
Once logged in to MySQL, run the following commands:
CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
EXIT;
Import the Cacti database schema:
mysql -u root -p cacti < /var/www/html/cacti/cacti.sql
Configuring Cacti Files
Copy the Cacti configuration file:
sudo cp /var/www/html/cacti/include/config.php.dist /var/www/html/cacti/include/config.php
Edit the configuration file:
sudo nano /var/www/html/cacti/include/config.php
Update the database settings:
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'your_password';
$database_port = '3306';
$database_ssl = false;
Setting up Cacti Web Interface
Create an Apache configuration file for Cacti:
sudo nano /etc/apache2/conf.d/cacti.conf
Add the following content:
Alias /cacti /var/www/html/cacti
<Directory /var/www/html/cacti>
Options +FollowSymLinks
AllowOverride None
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
Restart Apache to apply the changes:
sudo systemctl restart apache2
Setting Up RRDtool and SNMP
Installing RRDtool
RRDtool should already be installed from our earlier steps. Verify its installation:
rrdtool --version
Configuring SNMP
Edit the SNMP configuration file:
sudo nano /etc/snmp/snmpd.conf
Add or modify the following lines:
rocommunity public
syslocation "Your Location"
syscontact admin@yourdomain.com
Restart the SNMP service:
sudo systemctl restart snmpd
Configuring Cron Jobs for Cacti
Creating Cron Job for Poller
Create a new cron job file:
sudo nano /etc/cron.d/cacti
Add the following line:
*/5 * * * * www-data php /var/www/html/cacti/poller.php >/dev/null 2>&1
Verifying Cron Job Execution
Check the Cacti log file to ensure the poller is running:
tail -f /var/www/html/cacti/log/cacti.log
Securing Cacti Installation
Implementing SSL/TLS
For enhanced security, configure Apache to use HTTPS:
sudo zypper install apache2-mod_ssl
sudo a2enmod ssl
sudo systemctl restart apache2
Generate a self-signed certificate or use Let’s Encrypt for a valid SSL certificate.
Configuring User Authentication
During the initial Cacti setup, you’ll be prompted to create an admin user. Use a strong, unique password for this account.
Setting up Access Controls
Cacti provides built-in user management. After installation, navigate to Console > Users to create additional users and assign appropriate permissions.
Basic Cacti Configuration
Adding Devices
To add a new device to Cacti:
- Log in to the Cacti web interface
- Navigate to Console > Devices
- Click “Add”
- Enter the device details (hostname, SNMP community, etc.)
- Click “Create”
Creating Graphs
To create a graph for a device:
- Go to Console > Graphs
- Click “Add”
- Select the device and graph template
- Configure graph settings
- Click “Create”
Customizing Templates
Cacti allows you to create custom graph templates:
- Navigate to Console > Templates
- Choose the type of template you want to create (Graph, Data Source, or Host)
- Click “Add”
- Configure the template settings
- Save the template
Troubleshooting Common Issues
Database Connection Problems
If you encounter database connection issues:
- Verify the database credentials in config.php
- Ensure the MySQL/MariaDB service is running
- Check MySQL logs for any errors
SNMP Configuration Errors
If SNMP data collection fails:
- Confirm SNMP is properly configured on both Cacti and the monitored devices
- Verify firewall settings allow SNMP traffic
- Use snmpwalk to test SNMP connectivity
Graph Generation Issues
If graphs are not generating:
- Check Cacti logs for RRDtool errors
- Ensure the web server has write permissions to the RRA directory
- Verify that the poller is running correctly
Optimizing Cacti Performance
Tuning MySQL/MariaDB
Optimize your database performance:
- Increase innodb_buffer_pool_size for better caching
- Adjust max_connections based on your Cacti usage
- Enable query caching for frequently accessed data
Adjusting PHP Settings
Fine-tune PHP for Cacti:
- Increase memory_limit if dealing with large networks
- Optimize max_execution_time for long-running scripts
- Enable opcache for improved PHP performance
Optimizing Polling Frequency
Balance data collection and system load:
- Adjust polling intervals based on device importance
- Use Spine poller for improved performance on large installations
- Consider distributed polling for very large networks
Congratulations! You have successfully installed Cacti. Thanks for using this tutorial to install the latest version of the Cacti web-based system monitoring on the openSUSE system. For additional help or useful information, we recommend you check the official Cacti website.