How to Install and Setup Cacti on Ubuntu 16.04

Hello and welcome to our today's article on another open-source Network monitoring tool that is Cacti. Cacti is a complete network graphing solution designed with RRDTool’s data storage and graphing functionality. It can graph network bandwidths with SNMP, shell or perl scripts. RRDtool is a program developed by the Swiss Tobi Oeticker who was already the creator of the famous MRTG. RRDtool is developed using the "C" programming language and it stores the collected data on ".rrd" files. The number of records in a ".rrd" file never increases, meaning that old records are frequently removed. This implies that one obtains precise figures for recently logged data, whereas figures based on very old data are mean value approximations. By default, you can have daily, weekly, monthy and yearly graphs.

Some of the primary features of Cacti are the following:

  • unlimited graph items
  • flexible data sources
  • custom data-gathering scripts
  • built-in SNMP support
  • graph templates
  • data source templates
  • host templates
  • user-based management and security
  • tree, list, and preview views of graph data
  • auto-padding support for graphs
  • graph data manipulation

Using Cacti you can easily monitor the performance of your computers, networks, servers, router, switch, services (apache, mysql, dns, harddisk, mail server), SANs, applications, weather measurements, etc. Cacti's installation is very simple and you don't need to be expert to complete its setup. You can also add plugins to the Cacti for enabling the possibility to integrate other free tools like ntop or php weathermap.

1) Prerequisites

The basic requirement for Cacti is that you must have LAMP stack setup on your server, before getting started with the installation of Cacti. Login to your Ubuntu server and run below command to update your Ubuntu server.

# apt-get update
# apt-get upgrade

Before installing the LAMP packages, please do note that Cacti do not support MySQL-Server-5.7 as yet. So, we will be using the 'MySQL-Server-5.6' by adding it repository and then update the system with below commands.

# add-apt-repository 'deb trusty universe'
# apt-get update

Now install the following packages for Cacti setup on your Ubuntu server with the help of given below command.

# apt-get install apache2 mysql-server-5.6 php libapache2-mod-php

Press 'Y' to continue installation on LAMP package including its additional required packages as shown.

LAMP installation

During the installation process, you will be asked to configure the root password of MySQL server. Press 'OK' after setting up the password and then repeat the same upon next prompt.

mysql passowrd

2) Install SNMP, SNMPD and RRDtools

We need to install few other packages that are necessary for fully functional Cacti setup and to monitor the 'localhost' where cacti is installed you need to install and configure the service 'snmpd'.

Run the below command to install these packages on your Ubuntu 16.04 server and press 'Y' key to continue.

# apt-get install snmp snmpd rrdtool
snmpd and rrdtools

3) Install Cacti on Ubuntu 16.04

Now we can start Cacti installation as we have completed all of its required dependencies. Issue the below command to start installing Cacti packages and press 'Y' to continue.

# apt-get install cacti cacti-spine
Installing Cacti

4) Configuring Cacti

During the installation process you will be prompted to configure Cacti with few options to select from available options. First of all Choose the web server that you wish to use for configure with Cacti like we are using Apache and then press 'OK' key to continue.

cacti web server

Next is to setup the database that is going to be used for Cacti . Point to the 'No' option if you have already configured databases or click on the 'Yes' to setup database using dbconfig-common for Cacti as shown.


Provide the database password for Cacti application to be used with database server.

cacti mysql password

Select the MySQL server connection type from the available options, for the best performance we will be choosing the default UNIX socket as shown.

database connection type

Then you will be asked to create a new mysql database user for Cacti to be used to connect with the database server.

mysql user for cacti

That's it, cacti installation and configuration setup is complete. Now make sure that all required services are active and running.

# service snmpd restart
# service mysql restart
# service apache2 restart

5) Cacti Web Installation Setup

Open the following url to start Cacti web configuration and click on Next to continue after reading cacti installation guide.

cacti setup

Select the type of installation as 'New Installation' and click on the NEXT button.

cacti new installation

Now check below and make sure all of these values are correct before continuing. If everything looks OK and there is no error in your installation, then hit Finish.

finish cacti setup

Then you need to enter 'admin' username and its password where as admin is default username and password for cacti as shown below.

Cacti Login

Modify the default password after first login and set some different password.

cacti password

Welcome To Cacti Home Page

After resetting cacti user password, you will be automatically directed towards its home page. That just looks like below.

Cacti Home

Now add new devices, or create new graphs. To view graphs of your localhost system, click on the graphs button and you will see multiple graphs of your local host server showing your system memory usage and load average etc.

cacti graphs view


In this article, you learn about the installation and configuration setup of Cacti on Ubuntu 16.04. Now you are able to use it in your own environment to get graph data for the CPU and network bandwidth utilization. You can also use it to monitor the network traffic by polling a router or switch via snmp. Hope you have enjoyed alot, so do not forget to share your thoughts, Thank you.

10 Comments... add one

  1. Nice tutorial, but the last steps didn't work out for me. The db-config at step 4 failed. The steps I followed to complete are:
    (re)start mysql
    dpkg-reconfigure cacti
    accept all proposed names and options

    • 1) Before installing cacti in Step 3, restart/start the mysql service with the command “service mysql restart” (this will probably start it for the first time but should still work, otherwise just use ‘start’ instead of ‘restart’ in the command).

      2) Run the command “update-rc.d mysql defaults” which starts mysql on boot. (After a restart sometime, after you finish the install, run the command “mysqladmin -u root -p status” to check the status of mysql (run as root if needed). The command should now show MySQL as running after a reboot). I noticed it was not starting up during the installation process nor starting on boot.

      3) Continue with Step 3

      Hope this helps.

      *the following is not confirmed*
      I read from another website not to use special characters in the MySQL user passwords for some reason, so I just used Alpha/Numeric in case that mattered as well. Maybe they were referring to the include/config.php file where cacti stores a password in plain text...maybe a special character could throw off the way that config file is read.

      • Hi,

        Thank you for clearance, the one reason I can imagine is guys are trying with the latest version of MySQL, but as I mention "Cacti do not support MySQL-Server-5.7". So, make sure to use to use 'MySQL-Server-5.6'.



    TO FIX THE PROBLEM follow these steps>

    1. Go the browser, enter the url localhost/cacti


    cd /usr/sbin

    and change the permission of the ' spine 'file.
    sudo chmod a+s spine

    enter the command:

    uptdate-rc.d mysql defaults

    sudo init 6.

    then the graphis are displayed well.

  3. hi ... i got a problem while installing it in the configuring cacti section (ERROR 2002 (HY000): Can not connect to local MySQL server through socket '/var/run/mysqLd/mysgLd.sock' ) please how to solve it?

    • I tried the following steps:

      1. Log in as super user or use sudo
      2. Open /etc/mysql/my.cnf using gedit
      3. Find or add bind-address, and change its value to the database server host machine's IP address. For me, it was localhost or
      4. Save and close the file.
      5. Come back to terminal and execute sudo service mysql start
      It worked for me.


Leave a Comment