• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Install Cacti from source on Ubuntu 14.04 LTS Server

June 20, 2015 by Sharad Chhetri

Cacti is very well known name in monitoring system. It is RRD tool based, gather the information by using external script/command and feed the data into RDBMS database like MySQL/MariaDB. Cacti frontend is basically written in PHP. We can use the SNMP to gather the information and feed into Cacti database . You can view the data in graphs managed by RRD tool in Cacti server.

Basic requirement to install cacti

  • Webserver : HTTPD (In this practical we are using Apache2)
  • php : Because Cacti has PHP based frontend.
  • php-mysql : PHP extension which will help PHP code to connect and manage the queries in MySQL Database server.
  • php-snmp : PHP extension to help php code to manage remote devices via the SNMP ( Simple Network Management Protocol ).
  • mysql : This is mysql client. To use the MySQL client to manage the MySQL server database use the command mysql. For eg. mysql -u root -p
  • mysql-server : This is RDBMS based MySQL Server .
  • net-snmp : Net-SNMP is a suite of software for using and deploying the SNMP protocol (v1, v2c and v3 and the AgentX subagent protocol).

Description of Cacti Server in our lab

Given below is description of our Cacti server in our lab.

Operating System : Ubuntu 14.04 LTS Server
Arch : x86_64
Database Server : MySQL Server 5.6
Web Server : Apache2
IP Address : 192.168.122.116

Install Cacti Pre-Requisite Requirement

Now install cacti pre-requisite requirement.

In ubuntu let’s first update the apt repo.

sudo apt-get update

Installing Apache, PHP, PHP extension, SNMP :

sudo apt-get install apache2 php5 php5-mysql php5-snmp snmp php5-gd

Installing RRD-Tool :

sudo apt-get install rrdtool

Install MySQL Server 5.6 : While installing mysql server, on screen you will see to set mysql root password. Hence, set the desired strong password.

sudo apt-get install mysql-server-5.6

Create system user for cacti

Create one system user for cacti. Later in this post you will know where we will use it.

sudo useradd cactiuser

Workaround in MySQL database server

In this section, we will create database and user for Cacti. We have granted all privileges to database user called cactiuser to database cactidb (see in queries given below) .

First login into mysql server, use the mysql root password which you have set while installing mysql server.

mysql -u root -p

Follow the given below queries in mysql database. Replace Password with strong password you want to set for cactiuser (database user)

mysql> create database cactidb;
mysql> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'Password';
mysql> GRANT ALL ON cactidb.* TO 'cactiuser'@'localhost'; 
mysql> flush privileges;
mysql> exit

Download and extract the Cacti tar ball

Download and extract the Cacti tar ball. We will copy the extracted out cacti source and rename as cacti in /var/www/html directory.

wget http://www.cacti.net/downloads/cacti-0.8.8d.tar.gz

tar -xvzf cacti-0.8.8d.tar.gz

sudo cp -prvf cacti-0.8.8d /var/www/html/cacti

Restore cacti database from dump file

Use the already available cacti.sql dump file to restore into Cacti database.

mysql -u root -p cactidb < /var/www/html/cacti/cacti.sql

Settings for Cacti in config.php

Edit the cacti include/config.php file.

sudo vi /var/www/html/cacti/include/config.php

Do the follow settings in config.php and set the correct values.

$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "Password";
$database_port = "3306";
$database_ssl = false;

$url_path = "/cacti/";

$cacti_session_name = "Cacti";

Set owner/group to cacti web directory

Change the Ownership and group of cacti web directory to apache user that is www-data .

chown -R www-data:www-data /var/www/html/cacti/

Change ownership of rra and log directory in cacti web directory with cactiuser (it is system user which we created in beginning of this post).

chown -R cactiuser /var/www/html/cacti/rra/ /var/www/html/cacti/log/

Set crontab for poller script

Edit /etc/crontab file

vi /etc/crontab

Add the following given line at end of crontab. The cron will be run by user cactiuser in every 5 minutes,daily.

## Cacti
*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1

Restart Web server

After completing all steps, restart the Apache.

sudo service apache2 restart

Follow the installation in Web browser interface

Now rest of installation process will be completed through web browser interface.
Open the web browser and type the IP address of cacti server suffix by /cacti .

For eg. our cacti server ip address is 192.168.122.116 , hence in web browser we will type http://192.168.122.116/cacti

Figure 1: You will get the "Cacti Installation Guide" on screen. Click on 'Next' button.

Cacti image

Figure 2: In next screen, you will get drop down button. Because this fresh installation select 'New Install' and click 'Next' button .

install cacti image

Figure 3: In next screen, you will see many information which mainly includes path of RRDtool, php, snmpwalk, snmpget, snmpbulkwalk, snmpgetnext, cacti log path, RRD tool version and SNMP version. Click 'Finish' button.
(in case, any dependency is not found you can not finish the installation)

cacti image

Figure 4: In next screen, you will get login form on screen.
By default username/password is admin/admin . Use the username and password in login form.

cacti password image

Figure 5:
In next screen, it will force you to set the new password for admin .

install cacti image

Now you are able to login into Cacti server with new password of adminuser and can set the monitoring.

The given below screenshots are after admin login into Cacti dashboard.

cacti-6

Some graphs of localhost. (Just wait for 5 minutes, you will see the graphs)

Cacti dashboard image

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. How to install Nagios 4 from source on Ubuntu 14.04 LTS
  2. Install Nginx from source code on Ubuntu 14.04 LTS
  3. Install osTicket ( Open source ticketing tool ) on Ubuntu 14.04 LTS
  4. Install redis 3.0 from source on Ubuntu 14.04 / CentOS 7 / RHEL 7
  5. How to install nginx webserver from source on CentOS and RHEL
  6. How to install nginx from source on CentOS 7
  7. The best Linux and Open Source Magazine from India
  8. Remove python module installed from source code on Linux
  9. Install Openssh server on Ubuntu Desktop / Server
  10. How to install and configure FTP server in Ubuntu 12.04 LTS

Filed Under: Linux Tagged With: cacti

Reader Interactions

Comments

  1. Christian says

    May 17, 2016 at 12:48 am

    Please help me, I have this error in browser:

    FATAL: Cannot connect to MySQL server on ‘localhost’. Please make sure you have specified a valid MySQL database name in ‘include/config.php’

    My config:
    /* make sure these values refect your actual database/host/user/password */
    $database_type = “mysql”;
    $database_default = “cactidb”;
    $database_hostname = “localhost”;
    $database_username = “cactiuser”;
    $database_password = “Passw0rd”;
    $database_port = “3306”;
    $database_ssl = false;

    /*
    Edit this to point to the default URL of your Cacti install
    ex: if your cacti install as at http://serverip/cacti/ this
    would be set to /cacti/
    */
    $url_path = “/cacti/”;

    /* Default session name – Session name must contain alpha characters */
    $cacti_session_name = “Cacti”;

    • sharad chhetri says

      May 19, 2016 at 2:38 am

      Hi Christian,

      Check by directly connecting from terminal.

      mysql -u cactiuser -p Passw0rd
      

      If you are not able to login with this user then login with root and reset the password of database user which you have created.

      Regards
      Sharad

  2. Ero says

    November 4, 2015 at 2:32 am

    that UI really needs a refresh.looks like a 1999 website

  3. yekyawthu says

    October 26, 2015 at 8:44 am

    Hello
    I am a newbie in Linux. I am now testing on Ubuntu 14.04 and I install cacti. Now I have trouble on how can I error or log message to my email and to my GSM phone to send notification message. How do I these case. Pls help me.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

rsync all files,hidden files,symlinks,hardlinks to remotes Linux Server

send email after mysql backup through bash script in simple way

How to set JAVA environment variables in Linux

The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form

Protect from w00tw00t.at.blackhats.romanian.anti-sec

set and unset line number in file with vi editor

How to change smtp port number 25 in postfix

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy