Cacti is a popular network graphing tool that allows you to monitor and graph various metrics about your network devices. Here’s how to install and configure Cacti on RedHat and CentOS:
- Install the necessary packages using the
yum
package manager:sudo yum install cacti cacti-spine httpd mariadb-server php php-mysqlnd net-snmp net-snmp-utils php-snmp -y
- Start the
mariadb
service and configure it to start automatically on boot:sudo systemctl start mariadb
sudo systemctl enable mariadb
- Run the
mysql_secure_installation
script to secure the MariaDB installation and set the root password:sudo mysql_secure_installation
- Create a new MySQL database for Cacti:
mysql -u root -p
CREATE DATABASE cacti;
GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit;
Replace ‘password’ with a strong password of your choice.
- Import the default Cacti database schema into the new
cacti
database:sudo mysql -u cacti -p cacti < /usr/share/doc/cacti/cacti.sql
Enter the password you set for the
cacti
MySQL user in step 4 when prompted. - Edit the Cacti configuration file
/etc/cacti/db.php
and set the MySQL database credentials:sudo vi /etc/cacti/db.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "password";
Replace ‘password’ with the password you set for the
cacti
MySQL user in step 4. - Edit the Apache configuration file
/etc/httpd/conf.d/cacti.conf
and add the following lines to allow access to the Cacti web interface from the local network:<Directory /usr/share/cacti/>
Options +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from 192.168.0.0/24
</Directory>
Replace
192.168.0.0/24
with the IP address range of your local network. - Edit the Cacti configuration file
/etc/cacti/cacti.conf
and set the timezone:sudo vi /etc/cacti/cacti.conf
date_default_timezone = "Europe/London"
Replace
Europe/London
with your timezone. - Start the Cacti and Apache services and configure them to start automatically on boot:
sudo systemctl start cacti
sudo systemctl enable cacti
sudo systemctl start httpd
sudo systemctl enable httpd
- Open your web browser and go to
http://<cacti-server>/cacti/
to access the Cacti web interface. The default login credentials areadmin
/admin
.
That’s it! You should now be able to use Cacti to monitor and graph various metrics about your network devices.