In this tutorial we’ll learn how to install and configure Cacti network monitoring tool in the latest version of Ubuntu 20.04 LTS. Cacti will be build and installed from source files during this guide.
Cacti is an open source monitoring tool created for monitoring networks, especially network devices, such as switches, routers, servers via SNMP protocol. Cacti interacts with end-users and can be administered via a web tool interface.
Pre-Requisites
LAMP Stack Installed on Ubuntu already installed on your box
Step 1: Install and Configure Prerequisites for Cacti
First of all, make sure to update the system by issuing the below command.
#apt update && apt upgrade
In your LAMP stack make sure the following PHP extensions are present in the system.
Next, log in to MariaDB or MySQL database from your LAMP stack installation and create a database for installing Cacti by issuing the following commands. Replace cacti database name, user and password to match your own configurations and choose a strong password for cacti database.
# mysql -u root -p mysql> create database cacti; mysql> grant all on cacti.* to ‘cactiuser’@’localhost’ identified by ‘p@$$w0rd’; mysql> flush privileges; mysql> exit
Also, issue the below commands to allow cacti user select permissions to MySQL data.timezone setting by issuing the below commands.
# mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql # mysql -u root -p -e ‘grant select on mysql.time_zone_name to cactiuser@localhost’
Next, open MySQL server configuration file and add the following lines at the end of the file.
# vi /etc/mysql/mariadb.conf.d/50-server.cnf [For MariaDB] # vi nano /etc/mysql/mysql.conf.d/mysqld.cnf [For MySQL]
Add the following lines to the end of the 50-server.cnf or mysqld.cnf file.
Start install Cacti from sources by downloading and extracting the latest version of Cacti archive and copy all the extract files to Apache web document root, by issuing the following commands.
Next, populate cacti database with the cacti.sql script from /var/www/html/ directory by issuing the below command.
# mysql -u cactiuser cacti -p < /var/www/html/cacti.sql
Now install some additional resources, as Cacti engine collects devices data via the SNMP protocol and displays graphics by using RRDtool. Install all of them by issuing following command.
Verify if SNMP service is up and running by restarting snmpd daemon by issuing the below command. Also check the snmpd daemon status and its open ports.
# systemctl restart snmpd.service # systemctl status snmpd.service # ss -tulpn| grep snmp
Step 3: Download and Install Cacti-Spine
Cacti-Spine is a C written replacement for the default cmd.php poller. Cacti-Spine provides a faster execution time. To compile Cacti-Spine pooler from sources install the below required dependencies in your system.
After you’ve installed the above dependencies, download the latest version of Cacti-Spine archive, extract the tarball and compile cacti-spine by issuing the following series of commands.
# wget https://www.cacti.net/downloads/spine/cacti-spine-latest.tar.gz # tar xfz cacti-spine-latest.tar.gz # cd cacti-spine-1.1.27/
Compile and install Cacti-Spine from sources by issuing the following commands.
# ./bootstrap # ./configure # make # make install
Next, make sure spine binary is owned by root account and set the suid bit for the spine utility by running the following commands.
Now, edit Cacti Spine configuration file and add the cacti database name, user and password to the Spine conf file as illustrated in the below example.
To install Cacti, open a browser and navigate to your system IP address or domain name at the following URL.
First, check Acept License Agreement and hit on the Next button to continue.
Next, check if system requirements and hit Next button to continue.
In the next window, select New Primary Server and hit on Next button to continue.
Next, verify critical binary locations and versions and change Spine binary path to /usr/local/spine/bin/spine. When finished, hit Next button to continue.
Next, check if all web server directory permissions are in place (write permissions are set) and hit on Next button to continue.
On the next step check all the templates and hit on Finish button in order to finish the installation process.
Log in to Cacti web interface with the default credentials shown below and change the admin password, as illustrated in the following screenshots.
Next, navigate to Console -> Configuration -> Settings -> Poller and change the Poller Type from cmd.php to Spine binary and scroll down to Save button to save the configuration.
Then, navigate to Console -> Configuration -> Settings -> Paths and add the following path to Cacti-Spine configuration file:
/usr/local/spine/etc/spine.conf
The final setup which enables Cacti poller to start collecting data from monitored devices is to add a new crontab task in order to query each device via SNMP every 5 minutes.
The crontab job must be owned by www-data account.
# crontab -u www-data -e
Add Cron file entry:
*/5 * * * * /usr/bin/php /var/www/html/poller.php
Wait a few minutes for Cacti to collect data and navigate to the Graphs -> Default Tree and there you will see the graphs collected for your monitored devices.
Congratulations! You have successfully installed and configured Cacti with Cacti-Spine pooler, from sources, in the latest release Ubuntu 20.04 LTS server.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsOK
Privacy & Cookies Policy
Privacy Overview
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.