Main Menu (suckerfish)

How to install Cacti in Debian Etch


What is Cacti?

cacti logo
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.

Why Cacti?

Cacti has a nice user interface. It is easy to install and easy to setup, don't need too much customization.

Downloading Cacti

You can download the newest version of Cacti from its website http://cacti.net/.

Installing Cacti

Install apache webserver with php support, mysql database server, snmp, some php modules and rrdtool.

apt-get install apache2 libapache2-mod-php5 php5 php5-cli php5-mysql php5-gd php5-snmp mysql-client mysql-server libmysqlclient15-dev snmp snmpd rrdtool

Add a user account for cacti.

groupadd cacti
useradd -g cacti cacti

Untar the cacti source file and move to /var/www.

tar -zxvf cacti-0.8.7b.tar.gz
mv cacti-0.8.7b /var/www

Login to your mysql database

mysql -u root

Create a password for your mysql root account and create cacti database and user.

SET PASSWORD FOR root@localhost = PASSWORD ('your_password_here');
CREATE DATABASE cacti;
GRANT ALL ON cacti.* TO cacti_user@localhost IDENTIFIED BY 'your_password';
quit

and import the database tables

cd /var/www/cacti-0.8.7b/
mysql -u root -p cacti < cacti.sql

Change the owner of rra and log directory to your cacti account.

chown -R cacti rra/ log/

Edit the config.php file located in include directory.

vi include/config.php

Enter your mysql host, user, password and database name.

/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "your_password";
$database_port = "3306";

As a cacti user

su - cacti
crontab -e

add this line to your crontab

*/5 * * * * /usr/bin/php /var/www/cacti-0.8.7b/poller.php > /dev/null 2>&1

Open up your web browser and point to http://localhost/cacti-0.8.7b/, this will start cacti installation. Click Next then select NEW INSTALL and accept the default installation value. If you don't see any errors, click Finish to install.

Login to cacti, the default username and password is admin. After login, it will prompt you change your password for security reasons.

Checking

Check your syslog if the cacti's poller is running every 5 minutes.
If you will see something like this in your syslog, your cacti should work perfectly.

Jul  5 06:50:01 server1 /USR/SBIN/CRON[6543]: (cacti) CMD (/usr/bin/php /var/www/cacti/poller.php > /dev/null 2>&1)

You can start monitoring your servers, routers and other networking devices with cacti.


Your rating: None Average: 5 (1 vote)
Cacti alerte par email : Le plugin thold | Artiflo Inside's picture

Pingback

chicosoft's picture

Syslog apear as Localhost

Hi, the machine where i have the syslog and the cacti is the same. when i go to syslog in cacti, the logs from that machine are saying from: localhost...

how can i change it?

Thanks.

chicosoft's picture

Syslog apear as Localhost

Hi, the machine where i have the syslog and the cacti is the same. when i go to syslog in cacti, the logs from that machine are saying from: localhost...

how can i change it?

Thanks.

webmaster's picture

It would be better to install from source....

IMHO a better way to install cacti is to grab the latest version from cacti's website or from sourceforge.net since binary package of cacti from Debian etch repo is quite outdated.

sed -i 's/windows/linux/' os

Anonymous's picture

Install cacti, the debian way...

Install cacti and friends... (aptitude should take care of the rest of the dependencies)
# aptitude install mysql-server cacti php5-cli

Open your web browser to,
http://host/cacti

..And login with,
admin:admin

Use the cacti web interface to configure the devices you want to monitor.

EOL

webmaster's picture

If you have problem installing...

If you have problem installing cacti 0.8.7b from www.cacti.net like this:

Notice: Undefined index: user in /var/www/cacti/lib/auth.php on line 34

Warning: Cannot modify header information - headers already sent by (output started at /var/www/cacti/lib/auth.php:34) in /var/www/cacti/include/auth.php on line 29

Delete that file and download a freh copy of cacti 0.8.7b from sourceforge.net.
sed -i 's/windows/linux/' os

Que Quotion's picture

FOUND THE PROBLEM.

something is funny about the editor when you log in as cacti through su. it wraps the command to the next line as you type. don't use su and just run

crontab -u cacti -e

from root.

then you can type the line normally and it scrolls over the edge rather than wrapping. this fixed it for me.

i am aware that it does not make much logical sense.

Que Quotion's picture

Bad hour error

I have the same problem as the above posts.

I think you should look into this a little more.

Is there some small difference we can't notice? are your asterisks the standard character?

crontab will not accept this line of code.

after saving the file, it says

":2: bad hour errors in file. cannot install."

Anonymous's picture

Error for plugin monitor

Invalid argument supplied for foreach() in /var/www/cacti-0.8.7b/plugins/monitor/monitor.php on line 199

When I click on monitor tab I am getting above error.

webmaster's picture

Apply this patch if you have error like this...

Please apply this patch if you have error like this:

cacti error

To apply patch, go to /var/www/cacti folder/ and download the patch

and run this command

patch -p1 -N < reset_each_patch.patch

sed -i 's/windows/linux/' os

webmaster's picture

I haven't used this...

Anonymous wrote:
Got one its a plugin (reportit) but cant get any manual or howto on how to create the reports.any idea? thanks for your usual support.

I haven't used this plugin yet, I think the installation is same on installing syslog plugin but the configuration is quite difficult. Anyway here's the link on how to configure the plugin. I will try this plugin too, I will contact you soon if I will succeed. BTW you might be interested in this plugin as well. I don't know your name yet, could you please register so I can contact you. I am inviting you also to post stories, tutorials or anything related to Linux and Open Source.

Anonymous's picture

Got one its a plugin

Got one its a plugin (reportit) but cant get any manual or howto on how to create the reports.any idea? thanks for your usual support.

webmaster's picture

Could you please explain what kind

Anonymous wrote:
Hi,

Got it running now. Your a savior. Thanks a lot. May i ask if what report plugins are available for cacti. i really need some sort of a reporter. thanks again for your usual support.

Hi, Could you please explain what kind of reporter plugin you need?

Anonymous's picture

Hi, Got it running now. Your

Hi,

Got it running now. Your a savior. Thanks a lot. May i ask if what report plugins are available for cacti. i really need some sort of a reporter. thanks again for your usual support.

webmaster's picture

Your syntax looks fine


Anonymous wrote:

Hi,

Im getting this error when i'm editing the crontab file with this line..

*/5 * * * * /usr/bin/php /var/www/cacti-0.8.7b/poller.php > /dev/null 2>&1

the error is "bad hour"

Can someone help to explain..tq

Your syntax looks fine. It should work, make sure you put space between each */5 * * * *.

*/5 * * * * /usr/bin/php /var/www/cacti-0.8.7b/poller.php > /dev/null 2>&1

I have the same syntax in my crontab and its working fine.

webmaster's picture

Hi, I'm sorry, I forgot to tell you that you need to


Anonymous wrote:

Hi,

Got it running but as i have observed under Select Host(s): no Hosts appear where we can choose from...does this need more tweaks? Any idea on how to go about it? Thanks for your usual support.

Hi, I'm sorry, I forgot to tell you that you need to install syslog-ng to be able to view syslog logs in cacti using the syslog plugin.

To install syslog-ng, type this command:

apt-get install syslog-ng

Edit your /etc/syslog-ng/syslog-ng.conf and find the following lines:

# sources

# all known message sources
source s_all {
        # message generated by Syslog-NG
        internal();
        # standard Linux log source (this is the default place for the syslog()
        # function to send logs to)
        unix-stream("/dev/log");
        # messages from the kernel
        file("/proc/kmsg" log_prefix("kernel: "));
        # use the following line if you want to receive remote UDP logging messages
        # (this is equivalent to the "-r" syslogd flag)
        # udp();
};

Uncomment the line # udp(); to receive logs from a remote machine trough the network.

# sources

# all known message sources
source s_all {
        # message generated by Syslog-NG
        internal();
        # standard Linux log source (this is the default place for the syslog()
        # function to send logs to)
        unix-stream("/dev/log");
        # messages from the kernel
        file("/proc/kmsg" log_prefix("kernel: "));
        # use the following line if you want to receive remote UDP logging messages
        # (this is equivalent to the "-r" syslogd flag)
        udp();
};

Add these following lines to the end of the file (still in your /etc/syslog-ng/syslog-ng.conf file).

destination d_mysql {
        pipe("/var/log/mysql.pipe"
        template("INSERT INTO syslog_incoming
        (facility, priority, date, time, host, message, seq, status)
        VALUES ( '$FACILITY', '$PRIORITY', '$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$HOST', '$MSG', '$SEQ', '$STATUS' );\n") template-escape(yes));
};

log {
        source(s_all);
        destination(d_mysql);
};

Create a script called syslog2mysql.sh in your /var/www/cacti-0.8.7b/plugins/syslog directory and these lines:

#!/bin/bash

if [ ! -e /var/log/mysql.pipe ]
then
mkfifo /var/log/mysql.pipe
fi
while [ -e /var/log/mysql.pipe ]
do mysql -u cactiuser --password=cactiuser cacti < /var/log/mysql.pipe >/dev/null
done

Then make the script executable by typing:

chmod +x /var/www/cacti-0.8.7b/plugins/syslog/syslog2mysql.sh

Then create the temporary MySQL insertion file (pipe file)

mkfifo /var/log/mysql.pipe

Edit your crontab as root user

crontab -e

And add this line

@reboot /var/www/cacti-0.8.7b/plugins/syslog/syslog2mysql.sh > /dev/null 2>&1

As a cacti user

su - cacti
crontab -e

add these line to your crontab

*/1 * * * * /usr/bin/php /var/www/cacti-0.8.7b/plugins/syslog/syslog_process.php > /dev/null 2>&1

It should be ok now
Anyway, here is my cacti with syslog plugin.

Anonymous's picture

Error editing crontab

Hi,

Im getting this error when i'm editing the crontab file with this line..

*/5 * * * * /usr/bin/php /var/www/cacti-0.8.7b/poller.php > /dev/null 2>&1

the error is "bad hour"

Can someone help to explain..tq

Anonymous's picture

Error editing crontab

Hi,

Im getting this error when i'm editing the crontab file with this line..

*/5 * * * * /usr/bin/php /var/www/cacti-0.8.7b/poller.php > /dev/null 2>&1

the error is "bad hour"

Can someone help to explain..tq

Anonymous's picture

Hi, Got it running but as i

Hi,

Got it running but as i have observed under Select Host(s): no Hosts appear where we can choose from...does this need more tweaks? Any idea on how to go about it? Thanks for your usual support.

Anonymous's picture

Thanks Mr. Cahilig its

Thanks Mr. Cahilig its working now. all i need to do is observe if logs are coming in. Your a savior.

webmaster's picture

A few plugins like syslog will require...


Anonymous wrote:

Hi i have installed syslog but then when i try to access the site and view syslog this error would appear:

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

the mysql username i have defined is the default from cacti ('cactiuser') the database name is also 'cacti' , password is 'cactiuser'. If i manually access mysql using 'cactiuser' as its user name and 'cactiuser' as its password i can access mysql. Both ntop and discover i have installed successfully.

Here is the listing from global.php and config.php

/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";

i hope you could assist me on this. Thanks a lot

A few plugins like syslog will require their own little tweaks or configuration changes to complete the installation of the plugin; you will need to consult the individual documentation of the Plugin. Anyway, to fix your problem; you need to import the syslog.sql located in the /var/www/cacti/plugin/syslog directory to your cacti database.

cd /var/www/cacti/plugins/syslog
mysql -u root -p cacti < syslog.sql

Edit the config.php, still under this directory and make sure it will look like this.

$syslogdb_type     = 'mysql';
$syslogdb_default  = 'cacti';
$syslogdb_hostname = 'localhost';
$syslogdb_username = 'cactiuser';
$syslogdb_password = 'cactiuser';
Anonymous's picture

syslog error

Hi i have installed syslog but then when i try to access the site and view syslog this error would appear:

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

the mysql username i have defined is the default from cacti ('cactiuser') the database name is also 'cacti' , password is 'cactiuser'. If i manually access mysql using 'cactiuser' as its user name and 'cactiuser' as its password i can access mysql. Both ntop and discover i have installed successfully.

Here is the listing from global.php and config.php

/* Default database settings*/
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";

i hope you could assist me on this. Thanks a lot

Anonymous's picture

Thanks that was a great

Thanks that was a great help. Its running now.

webmaster's picture

Here's how to install plugins in Cacti...

I assume that you follow my tutorial about Cacti installation. Before you install your plugin, you have to download the Cacti's plugin Architecture from here and move to /var/www/ directory.

wget http://cactiusers.org/downloads/cacti-plugin-arch.zip
mv cacti-plugin-arch.zip /var/www
cd /var/www/
unzip cacti-plugin-arch.zip

There are two ways to install Cacti's plugin Architecture, by using pre-patch files and patch file.

The easiest way to install plugin architecture is using pre-patch files. Just copy all the files from files-0.8.7b directory to your cacti directory.

cp -rf files-0.8.7b/* cacti/

If you want to install using patch file, the command is slightly different. Please check if you have patch installed in your system, if you don't have it; please install it. Move the cacti-plugin-0.8.7b-PA-v2.1.diff to your cacti directory.

apt-get install patch
mv cacti-plugin-0.8.7b-PA-v2.1.diff cacti/

Then go to your cacti directory and type this command in the console:

patch -p1 -N --dry-run < cacti-plugin-0.8.7b-PA-v2.1.diff

If you don't see any errors, install the patch.

patch -p1 -N < cacti-plugin-0.8.7b-PA-v2.1.diff

Then import the pa.sql from your /var/www/ directory to your cacti database.

cd ..
mysql -u root -p cacti < pa.sql

Configure your cacti installation after installing the plugin architecture, edit your cacti/includes/global.php

vi +59 cacti/include/global.php

and make sure it will look like this:

$config['url_path'] = '/cacti/';

Thats it, your cacti is updated and it support plugins. To install plugins, just download the plugins, extract and move to cacti/plugins directory. For example I will install the monitor plugin.

wget http://cactiusers.org/downloads/monitor.gzip
tar -zxvf monitor.gzip
mv monitor cacti/plugins

Then edit your cacti/includes/global.php to activate the plugin.

vi +44 cacti/includes/global.php

uncomment the //$plugins = array(); and //$plugins[] = 'thold';, then add the $plugins[] = 'monitor';. The plugin configuration should look like this:

$plugins = array();
$plugins[] = 'thold';
$plugins[] = 'monitor';

Login to your cacti interface, click the Console tab>>User Management>>Select admin>>in the Realm Permissions, check the Plugin Management, View Host Info, and the View Monitoring checkbox.
source:
http://cactiusers.org/wiki/PluginArchitectureInstall
http://cactiusers.org/wiki/PluginsInstall

Anonymous's picture

plugins

do you happen to have a howto on how to install the plugins? I tried installing the plugin architecture based on the manuals i've search thru the web i just seem not to run.i would like to install the syslog plugin....but cant just make the archetecture work....the directories refered by the mauals is so confusing. im using debian etch.

webmaster's picture

Cool! No problem...

Cool! No problem, I'm glad to help.

Anonymous's picture

Debian Etch - Cacti

Thanks a lot your Howto really works. I had it installed from a Debian Etch clean install. More power.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may quote other posts using [quote] tags.

More information about formatting options