How to install Cacti SNMP Monitor on Ubuntu

Cacti is an open source web-based front end for the RRDtool that stores all the necessary information to display network and system graphics. Cacti makes use of the Simple Network Management Protocol to gather and monitor traffic from network devices, and can be installed on various Linux distributions. I'm going to walk you through the process of installing Cacti on Ubuntu 16.04 Server. The installation is quite involved and the majority of it is handled via the terminal. So log into your Ubuntu 16.04 server and prepare to type.

Configuring apt and update/upgrade

The first thing to do is to add the necessary repositories to apt. To do this create a new file with the command sudo nano /etc/apt/sources.list.d/cacti.list and add the following content:

If you have a firewall running, you'll need to open it up with the following command:

sudo ufw allow 80/tcp

Configure php

There are two lines to configure in /etc/php/7.0/apache2/php.ini. These two lines are:

file_uploads = Ondate.timezone =

If file_uploads isn't set to On, change it. You will also need to set your timezone. Find out your PHP-friendly timezone from the official PHP timezone listing. With those configurations in place, save and close the file and then restart Apache with the command:

sudo systemctl restart apache2

The database

Cacti stores its data in an RDBMS database. To make that happen, we'll configure Cacti to work with MariaDB. Install this database with the command:

The final command will prompt you to answer a few questions. The first will be to enter the current password for the root user. Since there is no password, hit Enter on your keyboard and then type y to change the root password. Type and verify the new password, and then answer the remainder of the questions with the default answers.

Now we have to create the new database. This is done first by logging into the database with the command:

mysql -h localhost -u root -p

After you authenticate, issue the following commands to create the new database:

create database cacti;grant all on cacti.* to 'cacti_user'@'localhost' identified by 'cacti_pass';flush privileges;exit

Next it is required to set permissions to the new database user according to the correct time zone. To do this, issue the following commands:

Next we configure Cacti-Spine to use our new database. Open the file /usr/local/spine/etc/spine.conf and edit the database credentials according to what you setup during the database installation/configuration. You'll need to change DB_User and DB_Pass.

Install Cacti

We finally get to the installation of Cacti. This is done with the following commands:

In similar fashion to Cacti-Spine, the Cacti configuration must be setup to connect to the database. Open the file /var/www/html/include/config.php and change the credentials as per the database install/configuration. You'll need to change database_username and database_password. In that same file, the line:

The last phase is to point your browser to http://SERVER_IP/install (Where SERVER_IP is the address of the server housing Cacti) and walk through the installation steps. Since we've already configured everything, this should require little more than clicking next a few times.

However, I did find one problem that took a bit of finagling to solve. The installer won't be able to find the spine executable. Out of the box, that executable is found in /usr/local/spine/bin. However, the installer wants it to be in /usr/local/spine/bin/spine/. To solve this, do the following:

cd /usr/local/spine/binmv spine ../mkdir spinemv ../spine spine/

It's an odd issue, but the above will take care of it.

After clicking Finish in the web installer, you'll be prompted to login. The default credentials are admin/admin. Once you enter those, you'll be prompted to set a new admin password (it must contain a mixture of upper/lowercase and at least one number). After that, you'll find yourself in the Cacti web interface where you can get busy working with your new installation of Cacti.