Pavel Tashev
Pavel Tashev / Entrepreneur and Software Developer
Constantly learning new things. I love to be part of projects and StartUps that inspire me and improve the life of society.
Contact me via LinkedIn or Twitter
Isle of Man, UK and Bulgaria
How to install Cacti Monitoring Server With Nginx

How to install Cacti Monitoring Server With Nginx

How to install Cacti Monitoring Server With Nginx


“Cacti is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-source, industry-standard data logging tool RRDtool. Cacti allows a user to poll services at predetermined intervals and graph the resulting data. It is generally used to graph time-series data of metrics such as CPU load and network bandwidth utilization.[2] A common usage is to monitor network traffic by polling a network switch or router interface via Simple Network Management Protocol (SNMP).” – Wikipedia

In this tutorial we will:

  • • Install Cacti.
  • • Configure Cacti to work with Nginx.
  • • Configure Cacti.
  • • Create devices and graphs.

All commands below are for Debian/Ubuntu Linux distribution.

Step 1 – Install Nginx

To install Nginx execute the command below.

sudo apt-get install nginx

That’s all, now we will continue with the set up of Snmpd.

Step 2 – Install SNMPD Service

SNMPD Service is used by Cacti, so it is a required component in order Cacti to work as expected. Let’s install it.

sudo apt-get install snmpd

After the installation we have to do few configurations.

nano /etc/default/snmpd

Find the row:

export MIBS=

and change it to:

export MIBS=ALL

Save and close the file. Open the configuration file:

nano /etc/snmp/snmpd.conf

For section “AGENT BEHAVIOUR” comment out the line for “connections from the local system only” and uncomment the line for listening for “connections on all interfaces”.

#  Listen for connections from the local system only
#agentAddress  udp:
#  Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161

Find the row:

# rocommunity public localhost       #  Full access from localhost

and uncomment it.

Next, search for and find the “ACCESS CONTROL” section and add the following record. We will be changing this to reference our specific Cacti server. Use either your cloud server’s domain name or its IP address.

rocommunity secret  CactiServerIpAddress

For example (if the IP address of our server is

rocommunity secret

Save and close the file.

The next step is to install MIB files. Here is short information for MIB:

A management information base (MIB) is a database used for managing the entities in a communications network. Most often associated with the Simple Network Management Protocol (SNMP), the term is also used more generically in contexts such as in OSI/ISO Network management model. While intended to refer to the complete collection of management information available on an entity, it is often used to refer to a particular subset, more correctly referred to as MIB-module.

Let’s install it:

sudo apt-get install snmp-mibs-downloader

Usually the installation should go with no issues but if you get this error “E: Package ‘snmp-mibs-downloader’ has no installation candidate”, that means that your are missing a source.list link. Let’s add it.

nano /etc/apt/sources.list

At the end of the file add:

deb precise main multiverse

Save and close the file. Try to install it again. This time it should work!

When you are ready with the installation of MIB files, restart SNMPD service.

sudo service snmpd restart

Step 3 – Install Cacti

sudo apt-get install cacti cacti-spine

During the installation of Cacti, you will be asked if you’d like dbconfig-common to setup MySQL for Cacti automatically. This creates a user and database for Cacti, and then imports the necessary data.

Installation of Cacti, step 1

You also will be asked to choose Web service. In our case choose “None/Others” because we will configure it to work with Nginx.

Installation of Cacti, step 2

Step 4 – Configure Cacti to work with Nginx

Let’s assume that in our case /var/www is the home directory where are located the websites which are pointing to our server. Let’s also assume that we would like to access Cacti from the domain name Let’s go to the home directory and create a directory for this domain name.

cd /var/www/
mkdir example

Now we have to create a record in “sites-available” in order Nginx to be able to handle properly requests sent from outside to this domain. Let’s go to this directory and create a new file for this domain.

cd /etc/nginx/sites-available/
nano example

Add the following code inside the file.

server {
        listen 80;

        root /var/www/example;
        index index.php index.html index.htm;


         location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

With the help of this configuration Nginx knows that all requests to the IP address of our server for this domain name and on port 80 must be forwarded to directory /var/www/example. Save and close the file.

Restart Nginx.

service nginx restart

Let’s go to the public directory for this domain.

cd /var/www/example/

Now we have to create a soft link between a sub-directory inside this domain name and the Cacti installation.

ln -s /usr/share/cacti/site cacti

This approach is helpful for those cases when the domain name already has an installed website, for example a blog or another web system, and we would like to access Cacti from

But if we want Cacti to be installed on an separate domain then we have to create the soft link between the directory example and the Cacti installation.

cd /var/www/
rm example
ln -s /usr/share/cacti/site example

When you are ready, you have to set up the proper permissions for the directory. In our case let’s assume that we have chosen the first option, to access Cacti from a sub-directory.

chgrp -R www-data example/
chown -R www-data example/
chmod -R 0755 example/

Step 4 – One-Time Setup of Cacti

Open your web browser and type the domain name in order to access Cacti. In our case this is: The first time when you open this domain you will see the screen displayed below. Choose “Next”.

Setup of Cacti, step 1

Choose “Next”.

Setup of Cacti, step 2

The next page shows the application paths of the “helper” applications that Cacti uses to operate. All of the applications should be green and marked with “[FOUND]”. Click “Finish” to continue.

Setup of Cacti, step 3

Next, you’ll be asked to enter the Cacti user name and password. These are not the passwords you entered during installation. Instead, enter the following default values.

Setup of Cacti, step 4

You are now on your Cacti page.

Setup of Cacti, step 5

Step 5 – Configure Cacti

A few options must be changed to ensure that Cacti produces data correctly. On the left-hand navigation panel, click on “Settings” under the Configuration heading.

In the General tab, we want to change some parameters. Change these settings to match what is shown here. Click “Save” when finished.

Configuration of Cacti, Settings

Next, click the “Poller” tab on the navigation settings. Change these options and match what is shown here. Click “Save” when finished.

Configuration of Cacti, Poller

Whenever the Poller Interval is changed, the cache must be emptied. To do this, click “System Utilities” under the Utilities heading.

Click on “Rebuild Poller Cache” to empty the cache.

Step 6 – Creating Devices and Graphs

To begin graphing, we need to set up device profiles and tell Cacti what to graph. Click “Devices” from the main left menu.

In the upper-right corner of the page, click the “Add” button to add a new device.

Now we have to fill in the fields displayed below. Click “Create” when you are finished.

Create new cacti device

If you see SNMP error in red at the top of the page, restart snmpd service from the Linux console. Click “Save” again when you are ready.

sudo service snmpd restart

Next, scroll down and create some associated graph templates and associated data queries.

Cacti - add graph templates

Cacti - add graph templates

Click “Create” at the bottom of the page when you are ready.

If you want like to change the graphs and the data collectors, click “Devices” from the left main menu and choose the device which you want to change. At the top of the page you will see three buttons: “Create Graphs for this Host”, “Data Source List” and “Graph List”. Choose “Data Source List” or “Graph List” in order to change the data sources or the graphs.

Cacti, change graphs

In order to see the data collected by Cacti, click “Graphs” tab at the top of the page. The collection of data might take a while (5 to 10 minutes) so if you come back in few hours you will see colorful graphs displaying the collected data.

Click on each graph to show daily, weekly, monthly, and yearly graphs for that same resource.

That’s from me for now. As always, any feedback in the comments is welcome!

Additional resources:
Set Nginx Load Balancing

Share me please:

Leave a Reply


Please type the text above: