Monitoring Ubuntu Servers and Desktops Using Cacti

Sponsored Link
Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for
LAN-sized installations up to complex networks with hundreds of devices.

Now we are going install Cacti from source code.If you are trying to install from source code you will have some advantages like latest version you can install.

WARNING: "this tutorial is meant for users that have a good knowledge of development tools and manual installation process and will be hardly supported by the Ubuntu community. Standard supported procedure are to install packages from the official repositories, not to compile them by hand".

Preparing Your server for Cacti

Install Apache Web Server with PHP support in Ubuntu Server

sudo apt-get install apache2 apache2-common apache2-mpm-prefork apache2-utils

sudo apt-get install libapache2-mod-php4 php4-cli php4-common php4-cgi

If you want to install php5 support use the following command

sudo apt-get install libapache2-mod-php5 php5-cli php5-common php5-cgi

This will complete the apache2 webserver installation

Install Mysql Server with php Support

sudo apt-get install mysql-server mysql-client libmysqlclient12-dev

sudo apt-get install php4-mysql

If you want to install php5 support use the following command

sudo apt-get install php5-mysql

Other Dependencies Installation

sudo apt-get install make gcc g++

sudo apt-get install cgilib libfreetype6 libttf-dev libttf2 libpngwriter0-dev libpng3-dev libfreetype6-dev libart-2.0-dev snmp

Install RRD Tool From Source

Now you need to download latest rddtool from here
sudo cd /usr/local/src/

sudo wget (at the time of writing this article)
sudo tar xfvz rrdtool-1.2.15.tar.gz

sudo cd rrdtool-1.2.15

sudo ./configure

sudo make

sudo make install

This will complete the RRD tool Installation from Source

Installing Cacti From Source

Now you need to download Latest Version of Cacti From here to your apache web server document root by default this is /var/www/ you can download if you changed your document root to some other path.

sudo cd /var/www/

sudo wget (At the time of writing)

Extract the distribution tarball.

sudo tar xzvf cacti-0.8.6i.tar.gz

Now you should have cacti-0.8.6i directory now you can move this to cacti directory

sudo mv cacti-0.8.6i cacti

Now you need to make sure that you have the correct permissions for inside cacti folders and files

sudo chown -R www-data:www-data rra/ log/

Create cacti database

First you need to create a database called cacti for this you need to use the following commands

$sudo mysql -u root

Promt for mysql root password

mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> quit

You can also use phpmyadmin to create database.

Import the default cacti database

sudo mysql cacti < cacti.sql Optional: Create a MySQL username and password for Cacti. sudo mysql --user=root mysql mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘somepassword';

mysql> flush privileges;

mysql> exit

I am creating cactiusers as mysql database user with password as cacti.

Now you need to Edit /var/www/cacti/include/config.php and specify the MySQL user, password and database for your Cacti configuration.

$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";

Enter a valid username for cactiuser, this user will also be used in the next step for data gathering.

Now we need to add the crontab for poller

sudo crontab -e

Add the following line ans save you can chnage the time whenever you want.

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

Replace cactiuser with the valid user specified in the previous step.

Replace /var/www/cacti/ with your full Cacti path.

Point your web browser to http://your-server-ip/cacti/ this will start with the following screen here click next

Here you need to select the type of installation and click next

Now it will check all the required paths are correct or not you can see this in the following screen

in the above screen RRD Tool Binary Path is showing as NOT FOUND because we have installed from source you need to
enter this line /usr/local/rrdtool-1.2.15/bin/rrdtool it will work without any problem and click finish.

If you don't want to install from souce and you can install from ubuntu package using the following command

sudo apt-get install rrdtool

If you install from package it will automatically detect the RRD Tool Binary path without problem.

Now you should see the Cacti Login screen as follows here you need to enter username and password as admin/admin and click login

first time it will prompt you to chnage cacti admin user password for security reasons and click save

You should see the following screen like below once you logged.

you need to make sure under configuration--->settings--->General RRDTool Utility Version option should be selected as RRD Tool 1.2.X Now your Cacti Monitoring Server is Ready and if you want to know how use cacti graphs and templates check here

You can monitor your Servers,Nework Devices and Many more with Cacti

If you want complete list of cacti templates check here

Sponsored Link

You may also like...

10 Responses

  1. Hi,
    just want to report broken link. has moved to new site, you can find it now at For the wget address of rrdtool I suggest to change the link “” to the new one at “” or the newest rrdtool-1.2.19.tar.gz.


  2. Tony says:

    Hey, this does not work with the default 6.10 install.

    root@cacti:~# sudo apt-get install cgilib freetype2 libttf-dev libttf2 libpngwriter0-dev libpng3-dev libfreetype6-dev libart-2.0-dev snmp
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Couldn’t find package freetype2

  3. Jordan K says:

    Anyone know why I might be getting the following error message when I point my browser to the cacti directory on my server? I did everything above without a hitch.

    Parse error: syntax error, unexpected T_LNUMBER in /var/www/cacti/include/config.php on line 33

  4. 67comet says:

    Looks like mine has an error too, but I can’t tell what it might be. I pointed my subdomain to cacti and I get a plain white page with nothing.

    Take a peek if you want.

    Thanks for any help,

  5. Maverick says:

    I’m having the same issue as Tony, no freetype2.

    Also, when I get down to: Import the default cacti database, I use the command as shown and get:

    ERROR 1049 (4200): unknown database ‘cacti’

    Any advice is much appreciated.

  6. admin says:

    @comment from songstruck

    I noticed that there were others (in the “Responses” section) with similar errors.
    As noted by Response 1, the download site has moved to: (latest version)

    As with the guys in Responses 2 & 5, I also had problems installing freetype2 with apt-get. I followed Oetiker’s build instructions here (his site also has a freetype2 binary for download):

    I received the same error as in Response 5, “unknown database ‘cacti’ “. You must first create the ‘cacti’ database in MySQL before executing “sudo mysql cacti < cacti.sql" at the command line. After going through all this (and all the troubleshooting), I found that you can now apt-get cacti in Ubuntu! I tried it, but as a Linux newbie, I'm still struggling with the concept of users/ownership in the various modules (apache2, mysql, etc.). Still, according to comments out there, it works for some. I'm not complaining; you warned that compiling by hand was not for wimps. I appreciate all your efforts on the Ubuntu Geek site. I wanted to give back, so I hope this is helpful for you and others. You have made my newbie experience a lot easier! Thanks. songstruck

  7. admin says:

    thanks songstruck

    I have updated the article now and freetype package also

  8. raymond says:

    hey all

    i tried full manual install on ubuntu 8.04
    i am using
    PHP 4.4.8 (cli)

    i struggled with almost each one, (fresh install) freetype, lib*, but in the end they all compiled without errors, and make and make install were taken care of as well 😉

    however, after finishing, i mean importing the cacti database, pointing to http://ip-address/cacti/ i get
    FATAL: Cannot connect to MySQL server on ‘localhost’. Please make sure you have specified a valid MySQL database name in ‘include/config.php’

    i understand that i need valid database name, but what does it mean? i mean, i got ubuntu up and installed all the stuff earlier mentioned, but this one has been driving me nuts for 2 days now. grants look ok, i chown-ed everything …
    i looked up the install guide provided by cacti, it’s a pdf file, did all that in exact manner. any ideeas? anyone?

    i am thinking to get all apache php mysql down and go
    apt-get install cacti
    but i thought maybe someone can help me out.
    P.S i can mysql -u cactiuser -p ‘password’ cactidb so it’s not a login issue.


  9. raymond says:

    I did a fresh install, since the machine is a test one, and followed the tutorial exactly, using php5; no errors, except a lil tuning for libraries, as some were old. Works like a charm. Thanks for a great guide!!!

  10. James says:

    Nearly fresh install using Ubuntu server 8.04 and php5:
    worked until # ./configure (missing libraries)

    Via rrdtool-1.3.4/doc/rrdbuild.txt:
    apt-get install libpango1.0-dev libxml2-dev

    Worked fine from there on! Thanks for the article.

Leave a Reply

Your email address will not be published. Required fields are marked *