Pavnay

 
  • Increase font size
  • Default font size
  • Decrease font size
FrançaisEnglish

[Monitoring] Cacti - Part 1 : Installation

Print
Monitoring
Among opensource monitoring softwares, Cacti is a reference. This software is divided into 2 parts : a front office, i.e. a graphical user interface declined as a website but also a tool which works periodically to get datas from others servers / services.

Cacti 's goal is to collect numeric infromation about servers and services health and represent them as charts.
To work, cacti  needs PHP, an application server as httpd by the Apache foundation, a databases server (MySQL) to store set-up and rrdtool to backup collected datas.

Cacti 's installation has several step but is quiet simple :

  1. rrdtool installation
  2. PHP installation and setting up
  3. Cacti's installation
  4. httpd setting up
  5. Data collector installation

rrdtool installation :


There are 2 ways to install rrdtool via the package manager or by compiling it.
Here, we compile it because the version (1.2.11) provided by the package manager is bugged for data representation and we prefere the 1.2.29 version :

apt-get install libfreetype6-dev libart-2.0-dev
cd /usr/local/packages
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.29.tar.gz
tar zxf rrdtool-1.2.29.tar.gz
cd rrdtool-1.2.29
./configure --prefix=/usr/local/rrdtool-1.2.29 && make && make install
cd /usr/local/
ln -s rrdtool-1.2.29 rrdtool



PHP installation and setting up :


We work on the assumption that a httpd server and a MySQL server are already installedsont déjà installés (respectively into /usr/local/apache2 and /usr/local/mysql).
Now, we install PHP with some modules :

apt-get install zlib1g-dev perl libdbd-mysql-perl libnet-snmp-perl libxml2-dev libxml2 libcurl3 libcurl4-gnutls-dev gawk libpng12-dev libmcrypt-dev snmp
cd /usr/local/packages
wget http://fr3.php.net/get/php-5.2.8.tar.gz/from/fr.php.net/mirror
tar xzf php-5.2.8.tar.gz
cd php-5.2.8
./configure --prefix=/usr/local/php-5.2.8 --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib --with-curl --enable-ftp --with-gd --with-mcrypt --with-mysql=/usr/local/mysql/ --with-snmp --enable-zip  --with-gnu-ld --enable-sockets
make
make install



Cacti's installation :


Cacti is a repository providing the website application but also data collector scripts.

cd /usr/local/packages
wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz
tar xzf cacti-0.8.7e.tar.gz 
mv cacti-0.8.7e /usr/local/.
cd /usr/local/
ln -s cacti-0.8.7e cacti


Now, we have to set up the database creating a dedicated database and giving rights to a new MySQL user :

CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY 'cacti';
FLUSH PRIVILEGES;



Creating the database's tables :

mysql -ucacti -pcacti cacti < /usr/local/cacti/cacti.sql


Then, the cacti's set up to connect to the databases server. Just edit the /usr/local/cacti/include/config.php file and adapt it depending the environment :

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



httpd setting up :


The website set-up under httpd is easily made adding in the httpd.conf or httpd-vhost.conf file :

Alias /cacti "/usr/local/cacti"
<Directory "/usr/local/cacti">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
    DirectoryIndex index.php
    AddType application/x-httpd-php .php
    php_flag magic_quotes_gpc Off
    php_flag short_open_tag On
    php_flag register_globals Off
    php_flag register_argc_argv On
    php_flag track_vars On
    # this setting is necessary for some locales
    php_value mbstring.func_overload 0
    php_value include_path .
    DirectoryIndex index.php
</Directory>


After an httpd restart (/usr/local/apache2/bin/apachectl restart) or a set-up reloading (/usr/local/apache2/bin/apachectl graceful), just connect to the cacti'sinterface (http://localhost/cacti).
When authenticating (by default with admin / admin), the interface asks to change password (recommended) then cacti is fully operational with a basic set-up for data collection.
Path to tools can be bad (for example rrdtool path if as here you have compiled it into a specific repository). To correct this, just indicate the right path to binaries.

Data collector installation :


Now, the visual cacti aspect is done, we have to install the data collector.
This program is very simple because it is a PHP script to install in the crontab (i.e. in the generic file /etc/crontab or in a user's crontab with the crontab -e command) :

*/5 *   * * *   /usr/local/php/bin/php /usr/local/cacti/poller.php >> /usr/local/cacti/log/poller.log


It's finished. Here, all 5 minutes, the data collector will be triggered all datas will be stored under the rrd format.

Comments
Add New
+/-
Write comment
Name:
Email:
 
Title:
 
:D:):(:0:shock::confused:8):lol::x:P:oops::cry:
:evil::twisted::roll::wink::!::?::idea::arrow:
 
DUPONT  - question   |2012-01-23 13:05:26
j'ai suivi la procédure pour installer cacti, merci tres bon tuto!
ma question
est que tout fonctionne mais je souhaite que cacti me donne les informations de
nagios et centreon qui sont sur le meme serveur, comment je dois faire?
merci
bien
mercier laurent  - installation du collecteur   |2012-03-20 10:50:44
merci pour votre tuto, petite question: pour la derniere partie
"installation du collecteur de données": j'ai fait la manip indiqué
mais il m'affiche "aucun fichier ou repertoire de ce type" pouvez vous
me dire ou faire cette manip
merci encore
laurent
Febbweiss   |2012-03-28 17:19:22
Je ne comprends pas bien l'erreur.

Pour configurer la crontab, ou bien vous
éditez le fichier /etc/crontab en ajoutant la commande ou bien vous faîtes
dans un terminal crontab -e (ce qui vous ouvre une crontab) et vous y ajouter la
commande.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Actualités


AddThis Social Bookmark Button