Today, we are going to learn that how we can Install Cacti on Ubuntu 18.04. Before proceeding further let’s have a short introduction on Cacti.
Cacti is a totally open-source network monitoring and graphing tool designed as a front-end software for the industry-trendy information logging tool RRDtool. Cacti harness the Power of RRDtool’s data storage and graphing functionality. Some suitable features of Cacti consist of:
- Rapid polling of metrics
- Assist for multiple information acquisition strategies
- Support for advanced graph template
- Consumer control functionality with ACL
Cacti offer an intuitive and smooth to use internet interface which may be used for small LAN installations up to complicated networks with lots of servers and networking devices. So, now we are going to start the installation of Cacti on Ubuntu 18.04.
Step 1: Update & Upgrade Your System
As usual, we do update & upgrade your Ubuntu 18.04 system to avoid any issues by typing
sudo apt-get udpate && sudo apt-get upgrade
Step 2: Installing PHP & Extensions
To install Cacti, we need the help of PHP and some extensions of PHP as they are the important part for the installation of Cacti on Ubuntu 18.04. Just fire the following command to install all of the required tools.
sudo apt-get -y install php php-mysql php-curl php-net-socket \
php-gd php-intl php-pear php-imap php-memcache libapache2-mod-php \
php-pspell php-recode php-tidy php-xmlrpc php-snmp \
php-mbstring php-gettext php-gmp php-json php-xml php-common
From the above extensions, the most necessary tools are php-snmp & php-mysql. So, double check that all these are installed successfully. After the installation of these tools, check the version of php you’ve just installed.
Open the file /etc/php/7.2/apache2/php.ini and set your correct timezone. You can view the current timezone by typing
grep date.timezone /etc/php/7.2/apache2/php.ini
Step 3: Installing Apache Server
Apache is one of the best web server that suits with the Cacti. So, install it by running
sudo apt-get -y install apache2
As the installation of Apache done, apply a security configuration to the Apache by permitting Prod ServerTokens only. Open the security.conf file with your favorite editor.
sudo nano /etc/apache2/conf-enabled/security.conf
And then change the line 18 to
Allow firewall to open http & https ports if you have enabled ufw.
ufw allow http
ufw allow https
Then, restart the Apache service to take effect of the required changes by hitting
sudo systemctl restart apache2
Step 4: Install Database MariaDB
Make sure that you’ve already installed MariaDB on your Ubuntu system. If you don’t know how to install it, then follow the below link to go to the MariaDB installation page first & then continue from here to Install Cacti on Ubunut 18.04.
After installing the database MariaDB, edit the file /etc/mysql/mariadb/mariadb.conf.
And under [mysqld] change the following setting to work properly.
Then restart MariaDB services.
sudo systemctl restart mysql
As the services restarted , create a new Database for Cacti:
mysql -u root -p
create database cacti;
grant all privileges on cacti.* to [email protected]'localhost' identified by 'yourpassword';
After it test the DB connection
mysql -u osradar -p
Step 5: Install Cacti on Ubuntu 18.04
Now, after completing the all requirements needed for the installation of Cacti proceed towards the Cacti installation.
As stated earlier, Cacti depends upon Snmp & rrdtool tool for its function. So, install them by
sudo apt-get install snmp snmpd snmp-mibs-downloader rrdtool cacti cacti-spine
When prompted to choose the web server, select Apache.
For Database Configuration, choose the option no for manually configuring as we have already created DB for Cacti. So, choose no
Wait for few moments to finish the Installation process & then proceed towards the SNMP configuration.
Step 6: Configuring SNMP
Comment the following line mibs: on /etc/snmp/snmp.conf file
Change mibs to #mibs
Edit the file /etc/snmp/snmpd.conf & go to line 49 to configure the SNMP community name.
rocommunity OSRadar localhost
Note:Use your desired name
Disable the community access by commenting the following lines
rocommunity public default -V systemonly
rocommunity6 public default -V systemonly
#rocommunity public default -V systemonly
#rocommunity6 public default -V systemonly
Then restart snmpd services.
sudo systemctl restart snmpd
Run the snmpwalk command line tool to validate the snmp configuration as seen below:
sudo snmpwalk -v 2c -c OSRadar localhost system
Note: Don’t forget to change OSRadar with the name of your community string as you entered earlier.
Step 7: Configuring Cacti Server
Now, it’s time to finish the installation of Cacti Server on Ubuntu 18.04. Go to the file /usr/share/cacti/site/include/config.php
And on line no 49 change the cacti database connection info as highlighted.
Note: Make sure to change the osradar user with the user you’ve created during database creation for Cacti.
Then import the Cacti MySQL database schema
mysql -u osradar -p cacti </usr/share/doc/cacti/cacti.sql
Provide your user name
And setup mysql timezone
Firstly grant Cacti MySQL database user access to Timezone database by
mysql -u root -p
GRANT SELECT ON mysql.time_zone_name TO [email protected];
And then setup the mysql timezone
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
Step 8: Finalizing Cacti Installation
As we’ve done all the necessary steps to Install & Configure Cacti on our Ubuntu system. So, now we are going to test our Installation. Go to your browser and type locahost/cacti or 127.0.0.1/cacti to finalized our Installation.
Accept the License Agreement and hit Begin button.
Then it will verify the requirements if they are okay.
Make sure that all requirements are okay.
And then hit “Next“
Here Select the type of Server, as we are going to Install our first Server so I’m selecting the Primary Server.
Then press “Next” button.
And check the Directory Permissions.
After it press “Next“.
Then click on the Finish button to finish the installation.
On the next page you’ll be asked to provide details of username & password. Provide admin admin in both fields. Then click on login.
For security reasons, you’ll be asked to change the password. So, choose the stronger password and then click “Save“.
Now, you’ll be directed to the Cacti Console.
Then Navigate to “Console>Devices” and add a new device to monitor it.
So, this is how we can Install Cacti on our Ubuntu 18.04.