Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X
Video

Cacti Pi – How to Install Cacti on Raspberry Pi

How to install Cacti on Raspberry Pi running Raspbian Wheezy

apt-get update
apt-get install apache2
apt-get install php5
apt-get install mysql-client mysql-server 

*you will be prompted to set a password for the mysql root user. take note of this as you will need it later!*

apt-get install php5-mysql php5-snmp rrdtool snmp snmpd

Run the following command to confirm required php modules are present:

php -m

mysql (For configuration, see note below)
SNMP (For configuration, see note below)
XML
Session
Sockets
LDAP (Required only when using LDAP authentication)
GD (Required only for some Plugins)

Edit php.ini to point to extension directory found in:

cd /usr/lib/php5/

The name of the extension directory which will likely be a number/date ie 20090626 or 20100525+lfs depending on your distro. My Raspberry Pi had the following:

vi /etc/php5/apache2/php.ini

extension_dir = /usr/lib/php5/20100525+lfs/

Edit Apache2.conf to point to php.conf:

vi /etc/apache2/apache2.conf

Include conf.d/*.conf

Create php.conf:

cd /etc/apache2/conf.d/

vi php.conf

Paste this in the file:

# PHP is an HTML-embedded scripting language which attempts to make
# it easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as
# directory indexes.
DirectoryIndex index.php

Download Cacti:

cd /var/www/

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

Untar Cacti:

tar xzvf cacti-0.8.8a.tar.gz

Rename the directory for uniformity:

mv cacti-0.8.8a cacti

Drop into the Cacti directory:

cd cacti

Create the MySQL database:

shell> mysqladmin --user=root -p create cacti

Import the default cacti database:

shell> mysql --user=root -p cacti < cacti.sql

Create a MySQL username and password for Cacti.

shell> mysql --user=root -p mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cacti';
mysql> flush privileges;

Edit include/config.php and specify the database type, name, host, user and password for your Cacti configuration.

vi include/config.php

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

Set the appropriate permissions on cacti’s directories for graph/log generation. You should execute these commands from inside cacti’s directory to change the permissions.

shell> chown -R www-data rra/ log/

Add a line to your crontab file:

vi /etc/crontab

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

Restart apache and mysql:

service apache2 restart

service mysql restart

Point your web browser to:

http://your-server/cacti/

Use ifconfig if you are unsure of your Raspberry Pi’s IP address

Log in the with a username/password of admin. You will be required to change this password immediately. Make sure all of the path variables show found on the following screen.

At this point you should have an operational install up and running with the default localhost being monitored for basic system info. In order to gather more info including processor and interface traffic edit the following:

cd /etc/snmp

cp snmpd.conf snmpd.conf_orig

vi snmpd.conf

Uncomment and edit the following:

#rocommunity secret 10.0.0.0/16

to:

rocommunity cacti

Then restart snmpd

service snmpd restart

You can now edit the host within cacti under console > device to allow for the use of snmp and add the snmp processor and interface data queries.

After allowing Cacti to complete a few polls you should have some thing like this:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

These instructions are specific to Raspberry Pi’s latest distro, however should work for any Linux distro with some slight variables here and there.

UPDATE : If after install you find that your graphs and/or Cacti’s log ( console > System Utilities > View Cacti Log File ) is not in your local timezone see my article on Correcting Cacti Timezone

Leave a comment below if you have any questions of run into any trouble.

  • Just want to say thanks for this AMAZING guide!
    Worked 100% and was quite easy to follow.
    Seems like you HAVE to update the php.ini with your timezone for the graphs to work.
    Here is a link to the supported timezones that you can maybe add :
    http://www.php.net/manual/en/timezones.php
    Looking forward to more posts!

    Gamma

    08/20/2012

  • Thanks for your comment GammaRSA! Glad the guide helped!

    In my experience in over 10 Cacti installs on Ubuntu, Debian and OSX, I have only had to update the php.ini files manually with a local timezone once. (see my post on Correcting Cact Timezone)

    I will definitely add the php supported timezones to that post as I also used it to correct that issue I saw where my cacti log and graphs were in UTC rather than EDT causing me to assume it wasn’t graphing. (due to me not looking far enough ahead to see the graphs on the Cacti ‘Graphs’ tab. Needed to change the graph filter preset to applicable UTC time.)

    Let me know what you utilize Cacti to monitor and how you’ve liked it this far!

    n00badmin

    08/20/2012

  • Love cacti so far!

    Mostly use it to monitor my few systems at home(Desktop PC, Server, Media center, other PI) but the main goal was for monitoring a private wireless network/hobby of mine that uses Mikrotik routers.

    Pi is running fine with about 10 devices with a average load of about 5-10%. But the thing that I am now concerned about is read/write on the SD card… I know the more devices I add the greater the I/O is going to be on the SD card since it writes quite a huge amount to log, so now I was wondering, did you add a Flashdisk or external storage for log files to reduce the load on the SD card or do you just leave it to write on the default path on the card? Since SD cards only have a limited read/write before they fail.

    Gamma

    09/05/2012

  • Working on a video version of this tutorial!

    Stay tuned!!!

    n00badmin

    08/20/2012

  • Video up! Enjoy!

    n00badmin

    08/22/2012

  • Thanks for the userful post!
    I ordered a Raspi with the purpose of replacing my old Slug as home network monitor, and cacti is something I was thinking to install.

    Could you please explain a bit your hardware configuration?
    Are you storing all data onto the SD card or do you have an additional USB stick or perhaps an HDD for that?

    bitwelder

    08/22/2012

  • Hey bitwelder,

    Posted a reply complete with current graphs over at raspberrypi.org

    http://www.raspberrypi.org/phpBB3/viewtopic.php?f=36&t=14581&p=156101#p156101

    To answer your question, I am storing all data to the /root partition on a 16GB SD card. I don’t forsee storage being an issue if running only Cacti as unless you are monitoring a large amount of devices and data points you should be fine as it’s very efficient. That being said I’ll likely look into adding a 500GB hard drive in the future.

    I highly recomment Cacti as it will provide you with endless ability to monitor, troubleshoot and report on you network and it’s elements. I will be posting on how to install plugins and reporting tools as well to enhance Cacti’s abilities so stay tuned and let me know if I can assist with your install!

    n00badmin

    08/22/2012

  • greeting
    I followed your tutorial and installed Cacti but in my experience these two error log and I appear blank charts

    08/31/2012 08:50:12 AM – CMDPHP: Poller[0] Host[1] DS[8] WARNING: Result from SNMP not valid. Partial Result: U

    08/31/2012 08:50:12 AM – CMDPHP: Poller[0] WARNING: SNMP Get Timeout for Host:’127.0.0.1′, and OID:’.1.3.6.1.4.1.9.2.1.58.0′

    gexe

    08/31/2012

  • Hey gexe!
    Thanks for checking out the tutorial!

    Can you please click the data source DS[8] link found under System Utilities > Cacti Log File and advise what you are trying to graph.

    A handy tip for troubleshooting SNMP errors or blank graphs is to manually walk the OID to see what the system returns.

    For example I walked this OID and here’s what I get on my Pi:

    pi@raspberrypi ~ $ snmpwalk -v2c -c c4ct1 192.168.2.5 .1.3.6.1.4.1.9.2.1.58.0
    SNMPv2-SMI::enterprises.9.2.1.58.0 = No Such Object available on this agent at this OID

    It appears this OID does not exist and would explain why you get a timeout.

    Out of curiosity I tried walking this OID against my Cisco Router:

    pi@raspberrypi ~ $ snmpwalk -v2c -c c4ct1 192.168.1.10 .1.3.6.1.4.1.9.2.1.58.0
    SNMPv2-SMI::enterprises.9.2.1.58.0 = INTEGER: 1

    Looks like I found your culprit. Can you confirm whether you have attempted to Graph Cisco CPU template?

    Let me know.

    Thanks

    n00badmin

    n00badmin

    08/31/2012

  • I solved the above problems removing CPU chart manually added. Now show me errors in my log but displays blank charts.

    gexe

    08/31/2012

  • What errors errors are you seeing. And what charts are blank?

    n00badmin

    08/31/2012

  • gexe,

    Please go to /var/www/cacti and run ls -lh and make sure www-data:www-data is the owner of the /rra and /log directories.

    if not complete
    chown -R www-data:www-data rra/ log/

    n00badmin

    08/31/2012

  • charts are empty … I do not show errors
    http://uploadimage.ro/images/70676065212608914738.jpg

    You can connect to me with TeamViewer if you want.

    gexe

    08/31/2012

  • Sounds good,

    I’m just driving into work…I’ll shoot you an email and we can do a teamviewer session.

    Talk to you shortly.

    n00badmin

    n00badmin

    08/31/2012

  • Hi, Was was the resolution with this one, I think I have the same problem and have checked all steps but cannot find the cause.

    takingthemick

    (great tutorial though)

    takingthemick

    09/13/2012

  • hey, thanks for checking the tutorial out.

    His issue was related to Cacti’s timezone. be sure to follow the Correcting Cacti Timezone post as you may be actually graphing , just not where you are looking.

    let me know if you require more assistance.

    n00badmin

    09/13/2012

  • I’ll check that now, although device shows status as ‘unknown’ although it gathers name, model, location etc in the SNMP details.

    rra directory is empty but the permissions/owner are set correctly.

    Will just confirm timezone though.

    takingthemick

    takingthemick

    09/13/2012

  • I’ve set my timezone now in both php.ini and rebooted but images
    still do not load and RRA directory is empty.

    Device shows status as ‘unknown’ although it gathers name, model, location etc in the SNMP details.

    rra directory is empty but the permissions/owner are set correctly.

    takingthemick

    takingthemick

    09/13/2012

  • If the RRA directory is empty it sounds like the poller is not running. Is /etc/crontab updated correctly? Check System Utilities > View Cacti Log, any errors?

    What graphs are you making?(Traffic, etc)

    What selection do you currently have under ‘downed device detection’? (ie SNMP uptime, Ping etc)

    Please also ensure your SNMP.conf file has been updated correctly and snmpd has been restarted. (sudo service snmpd restart)

    Let me know if you still have issues.

    n00badmin

    09/13/2012

  • drwxr-xr-x 2 www-data www-data

    gexe

    08/31/2012

  • drwxr-xr-x 2 www-data www-data 4.0K Apr 4 04:49 log

    drwxr-xr-x 2 www-data www-data 4.0K Aug 31 09:30 rra

    gexe

    08/31/2012

  • Thanks for your help … just waiting for other interesting tutorials.

    gexe

    08/31/2012

  • Glad I could help get you up and running!!!

    n00badmin

    08/31/2012

  • Is there a reason you got cacti from the site, rather than just doing an apt-get install cacti?

    When I run apt-cache search cacti, I see both Cacti and the Cacti Spine are available.

    I’m a complete newbie to LAMP in general, so this tutorial looks very helpful.

    Geoff

    09/13/2012

  • Hi Geoff,

    Apt-Get would work fine, however I wanted to be sure I was getting 0.8.8a and I wanted to control where Cacti and its elements were installed.

    n00badmin

    09/13/2012

  • I get a HTTP Error 500 (Internal Server Error) when trying to navigate to cacti for the first time. I made a test php page in the cacti dir and that works fine. I’m a bit of a linux noob and cant figure it out! Any ideas?

    Thanks

    Danger

    11/07/2012

  • Since my last post I’ve installed from a fresh raspian image and it worked fine…. Must of played with somthing on the previos Pi :(

    Danger

    11/19/2012

  • Thanks for the info – great to use and very helpful. I’m up and running on my pi. A couple of suggestions: 1. for the cron job, I directed the output to a logile in the same dir as the cacti log, very helpful to work out why rrd stopped working when I changed the timezone!! Also, 2. do you need to do “apt-get upgrade” after the update in the beginning for the changes to be applied?

    Colin

    11/24/2012

  • followed the tutorial, not one error until i attempt to go to http://myserverip/cacti

    Nothing, server error, page not found. I read through the tutorial again,,,the apache server is working as I get the default “its working” page when I got to the http://myserverip

    What have I missed? Seems like apache is loading files from the www root, and not from the cacti directory inside of www

    thank you

    piface

    piface

    12/26/2012

  • hey check the permissions of your cacti directory.

    ls -lh

    what do you get?

    n00badmin

    01/03/2013

  • Not sure if I am missing something here but I cannot even install apache! Get loads of unresolved dependencies from apt :(

    Aaron

    01/13/2013

  • Hello, I installed cacti regarding this Tutorial, but on my raspberry the “treeview” looks different than on other “cactis”: http://www.imgbox.de/users/public/images/MawpMqRcS1.jpg

    i installed cacti also on an debian-linux regarding this tutorial and there it looks normal: http://www.imgbox.de/users/public/images/ybhzEmSIxI.jpg

    is there an package which i need to install additionaly on the Pi ?
    Thx

    Kevin

    03/20/2013

  • Hey Kevin, the difference was subtle at first, but interesting question, you can see in the tutorial vi at 24:35ish I have you “normal” one displaying while viewing on mac osx in firefox after completing this install.

    what browser are you using to view? what version of cacti are you running? 0.8.8a??

    n00badmin

    03/24/2013

Leave a comment  

name*

email*

website

Submit comment