Vous êtes sur la page 1sur 23

Comment installer Nagios, Centreon et Nagvis sous Redhat ou CentOs?

Ce tuto vous permettra dinstaller le trio Nagios, Nagvis et Centreon avec NDOutils trs facilement sur Redhat ou CentOs.

Prrequis :
Vous pouvez les tlcharger avec ces liens.

Nagios 3.4.1 core Nagios plugins 1.4.15 Centreon 2.3.8 Ndoutils 1.4b9

Pour sauvegarder ou restaurer votre installation et votre configuration laide dun script suivez ce lien : Sauvegarder et Restaurer Nagios, Centreon et Nagvis On installe tous les packages ncessaires :
yum -y install make gcc php-pear* mysql mysql-server php-mbstring mysqldevel httpd net-snmp php-mysql gd-devel perl-GD perl-Config-IniFiles perlCrypt-DES perl-Digest-HMAC perl-IO-Socket-INET6 perl-Net-SNMP php-ldap phpsnmp perl-Socket6 php-gd php-xml mlocate sendmail openssh-clients php-posix mailx system-config-network-tui ntp rrdtool rrdtool-devel php-rrdtool perlrrdtool net-snmp-utils bc

Tous les packages qui ne sinstalleront pas devront tre tlchargs et installs manuellement sur : Pour 64 bits : http://dl.fedoraproject.org/pub/epel/5/x86_64/repoview/ Pour 32 bits : http://dl.fedoraproject.org/pub/epel/5/i386/repoview/ Le site de rfrence est : http://fedoraproject.org/wiki/EPEL

Installation de Mysql
1

On lance Mysql-Server, Apache, et on cre un user nagios :


# # # # # # chkconfig mysqld on service mysqld start chkconfig httpd on service httpd start user add nagios reboot

Ensuite, on tlcharge tous les packages ncessaires (si ce nest pas dj fait) :
# # # # # # # cd /root mkdir centreoninst cd centreoninst wget http://tuto-web.fr/DL/centreon-2.3.8.tar.gz wget http://tuto-web.fr/DL/nagios-3.4.1.tar.gz wget http://tuto-web.fr/DL/nagios-plugins-1.4.15.tar.gz wget http://tuto-web.fr/DL/ndoutils-1.4b9.tar.gz

Installation de NTP (synchro horloge).


# # # # yum install ntp chkconfig ntpd on ntpdate pool.ntp.org service ntpd start

Installation de Nagios
# # # # # # # # # tarxvzf nagios-3.4.1.tar.gz cd nagios ./configure make all make install make install-init make install-commandmode make install-config make install-webconf

Cration dun password pour linterface de Nagios


# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin # chkconfig nagios on # service nagios start

Installation des plugins :


cd .. # tar xvzf nagios-plugins-1.4.15.tar.gz # cd nagios-plugins-1.4.15 #./configure # make # make install

Installation de NDOutils 1.4b9 :


2

# cd .. # tar xvzf ndoutils-1.4b9.tar.gz # cd ndoutils-1.4b9 # ./configure --disable-pgsql --with-mysql-lib=/usr/lib64/mysql --withndo2db-user=nagios --with-ndo2db-group=nagios

Pour un OS 32 bits utiliser : with-mysql-lib=/usr/lib/mysql


# # # # make make install make install-init chown nagios:nagios /usr/local/nagios/bin/ndo*

Ndomod a besoin de deux fichiers pour fonctionner correctement, on les importent :


mv /root/centreoninst/ndoutils-1.4b9/config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg mv /root/centreoninst/ndoutils-1.4b9/config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg

chown nagios:nagios /usr/local/nagios/etc/ndo*


vi /usr/local/nagios/etc/ndomod.cfg instance_name=Central output_type=unixsocket output=/usr/local/nagios/var/ndo.sock tcp_port=5668 output_buffer_items=5000 buffer_file=/usr/local/nagios/var/ndomod.tmp

vi /usr/local/nagios/etc/ndo2db.cfg ndo2db_user=nagios ndo2db_group=nagiosgrp socket_type=unix socket_name=/usr/local/nagios/var/ndo.sock tcp_port=5668 db_servertype=mysql db_host=localhost db_name=ndo db_port=3306 db_prefix=nagios_ db_user=ndouser db_pass=ndopassword

vi /usr/local/nagios/etc/nagios.cfg event_broker_options=-1 broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg Le broker_module tiens sur une seule ligne !!!

Pour que votre configuration soit prise en compte, il faut lancer NDO et relancer Nagios:

# /etc/init.d/ndo2db start # /etc/init.d/nagios restart

Si tout se passe bien, Nagios devrait commencer crire les informations dans la base de donnes MySQL. Pour vous en assurer, allez voir du ct du fichier de log si vous avez les messages suivants:

tail -f /usr/local/nagios/var/nagios.log ... [1234886298] Auto-save of retention data completedsuccessfully. ...

Configuration de la base de donne NDO


Pour que NDO2DB puisse crire des informations dans la base de donne, il faut la crer et la configurer. Cration de la base de donnes MySQL NDO:
# mysqladmin -u root -p create ndo # mysql -u root -p mysql mysql> GRANT ALL ON ndo.* TO ndouser@localhost IDENTIFIED BY 'ndopassword'; Query OK, 0 rowsaffected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rowsaffected (0.00 sec) mysql> exit

Configuration :
# cd db # ./installdb -u ndouser -p ndopassword -h localhost -d ndo Table nagios.nagis_dbversion doesntexistat ./installdb line 51

Remarque: vous pouvez ignorer lerreur. On lance le service NDO et on lajoute automatiquement au dmarrage :
# service ndo2db start # chkconfig ndo2db on

Installation de Nagvis :
Tlchargez la dernire version de Nagvis ladresse :
4

http://sourceforge.net/projects/nagvis/files/NagVis%201.7/ On installe les modules PHP avec la commande yum.


# yum install php php-gd php-mysql php-mbstring php-xml php-common

php-session nest pas prsent dans les dpts, mais ce paquet est compris dans le paquet phpcommon dj install normalement mais on le remet pour tre sr.
# yum install graphviz

Si la commande ne passe pas, allez dans le dossier et installez graphviz via les rpm tlchargs sur le site http://fedoraproject.org/wiki/EPEL. Nagvis 1.4 demande une version suprieur 2.14 de graphviz or dans le dpt EPEL, ce sont les version 2.12 qui sont fournit. Cela fonctionnera mais il est prfrable de trouver les versions suivantes et les installer.
# # # # # rpm rpm rpm rpm rpm -ivh -ivh -ivh -ivh -ivh graphviz-2.22.2-1.el5.i386.rpm graphviz-doc-2.22.2-1.el5.i386.rpm graphviz-gd-2.22.2-1.el5.i386.rpm graphviz-graphs-2.22.2-1.el5.i386.rpm graphviz-perl-2.22.2-1.el5.i386.rpm

# tar xvzf nagvis-1.7.9.tar.gz # cd nagvis-1.7.9

On lance linstall :
# ./install.sh +-----------------------------------------------------------------------------+ | Welcome to NagVis Installer | +-----------------------------------------------------------------------------+ | This script is built to facilitate the NagVis installation and update | | procedure for you. The installer has been tested on the following systems: | | - Debian Etch, Hardy (4.0, 5.0) | | - Ubuntu Hardy, Intrepid, Jaunty, Karmic, Lucid (8.04 to 10.04) | | - SuSE Linux Enterprise Server 10 and 11 | | | | Similar distributions to the ones mentioned above should work as well. | | That (hopefully) includes RedHat, Fedora, CentOS, OpenSuSE | | | | If you experience any problems using these or other distributions, please | | report that to the NagVis team. |

+-----------------------------------------------------------------------------+ | Do you want to proceed? [y]: y +-----------------------------------------------------------------------------+ | Starting installation of NagVis 1.7.9 | +-----------------------------------------------------------------------------+ | OS : Debian GNU/Linux 5.0 | | Perl: 5.010000 | | | +--- Checking for tools ------------------------------------------------------+ | Using packet manager /usr/bin/dpkg found | | | +--- Checking paths ----------------------------------------------------------+ | Please enter the path to the nagios base directory [/usr/local/nagios]: | nagios path /usr/local/nagios found | | Please enter the path to NagVis base [/usr/local/nagvis]: | | +--- Checking prerequisites --------------------------------------------------+ | Nagios Core 3.2.3 found | | PHP 5.2 found | | PHP Module: gd 5.2 found | | PHP Module: mbstring compiled_in found | | PHP Module: gettext compiled_in found | | PHP Module: session compiled_in found | | PHP Module: xml compiled_in found | | Apache mod_php found |

Rpondre y pour le backend ndo2db et n pour les autres backend que nous nutiliserons pas.
| Checking Backends. (Available: mklivestatus,ndo2db,ido2db,merlinmy) | | Do you want to use backend mklivestatus? [y]: n | Do you want to use backend ndo2db? [n]: y | Do you want to use backend ido2db? [n]: n | Do you want to use backend merlinmy? [n]: n | /usr/local/nagios/bin/ndo2db-3x (ndo2db) found | | PHP Module: mysql 5.2 found |

| Graphviz 2.20 found | | Graphviz Module dot 2.20.2 found | | Graphviz Module neato 2.20.2 found | | Graphviz Module twopi 2.20.2 found | | Graphviz Module circo 2.20.2 found | | Graphviz Module fdp 2.20.2 found | | | +--- Trying to detect Apache settings ----------------------------------------+ | Please enter the web path to NagVis [/nagvis]: | Please enter the name of the web-server user [www-data]: | Please enter the name of the web-server group [www-data]: | create Apache config file [y]: y

Configuration Apache, valider par dfaut.


| | +--- Checking for existing NagVis --------------------------------------------+ | | +-----------------------------------------------------------------------------+ | Summary | +-----------------------------------------------------------------------------+ | NagVis home will be: /usr/local/nagvis | | Owner of NagVis files will be: www-data | | Group of NagVis files will be: www-data | | Path to Apache config dir is: /etc/apache2/conf.d | | Apache config will be created: yes | | | | Installation mode: install | | | | Do you really want to continue? [y]: y

Rpondre y pour raliser linstallation.


+-----------------------------------------------------------------------------+ | Starting installation |

+-----------------------------------------------------------------------------+ | Creating directory /usr/local/nagvis... done | | Creating directory /usr/local/nagvis/var... done | | Creating directory /usr/local/nagvis/var/tmpl/cache... done | | Creating directory /usr/local/nagvis/var/tmpl/compile... done | | Creating directory /usr/local/nagvis/share/var... done | | Copying files to /usr/local/nagvis... done | | Creating main configuration file... done | | setting backend to ndomy_1 done | | Creating web configuration file... done | | Setting permissions for web configuration file... done | | | | | | | +--- Setting permissions... --------------------------------------------------+ | /usr/local/nagvis/etc/nagvis.ini.php-sample done | | /usr/local/nagvis/etc done | | /usr/local/nagvis/etc/maps done | | /usr/local/nagvis/etc/maps/* done | | /usr/local/nagvis/etc/automaps done | | /usr/local/nagvis/etc/automaps/* done | | /usr/local/nagvis/share/userfiles/images/maps done | | /usr/local/nagvis/share/userfiles/images/maps/* done | | /usr/local/nagvis/share/userfiles/images/shapes done | | /usr/local/nagvis/share/userfiles/images/shapes/* done | | /usr/local/nagvis/var done | | /usr/local/nagvis/var/* done | | /usr/local/nagvis/var/tmpl done | | /usr/local/nagvis/var/tmpl/cache done | | /usr/local/nagvis/var/tmpl/compile done |

| /usr/local/nagvis/share/var done | | | +-----------------------------------------------------------------------------+ | Installation complete | | | | You can safely remove this source directory. | | | | For later update/upgrade you may use this command to have a faster update: | | ./install.sh -n /usr/local/nagios -p /usr/local/nagvis -B /usr/local/nagios/bin/nagios -b ndo2db -u www-data -g www-data -w /etc/apache2/conf.d -a y | | | What to do next? | | - Read the documentation | | - Maybe you want to edit the main configuration file? | | Its location is: /usr/local/nagvis/etc/nagvis.ini.php | | - Configure NagVis via browser | | | | - Initial admin credentials: | | Username: nagiosadmin | | Password: nagiosadmin | +-----------------------------------------------------------------------------+

Accs la page daccueil qui liste les cartes dfinies.http://serveur.domaine.local/nagvis/nagvis/index.php La page daccueil est aussi accessible cette URL. http://serveur.domaine.local/nagvis/ Accs la page de configuration web http://serveur.domaine.local/nagvis/config.php

Configuration Nagvis
Le fichier de configuration gnral est lorigine une copie du fichier example.
cd /usr/local/nagvis/etc/ cp nagvis.ini.php-sample nagvis.ini.php

Par dfaut tout est en commentaire, Il faut simplement dcommenter ce dont on a besoin. Pour plus de clart les sections en commentaires ne sont pas reprsentes mais uniquement ce qui a t modifi.
vi /usr/local/nagvis/etc/nagvis.ini.php [global] dateformat="Y-m-d H:i:s" language="fr_FR" refreshtime=20 [paths] base="/usr/local/nagvis/" htmlbase="/nagvis" htmlcgi="/nagios/cgi-bin" [defaults] backend="ndomy_1" [index] [automap] defaultroot="NOMSERVEUR" [wui] [worker] [backend_ndomy_1] backendtype="ndomy" dbhost="localhost" dbport=3306 dbname="ndo" dbuser="ndouser" dbpass="ndopassword" dbprefix="nagios_" dbinstancename="Central" maxtimewithoutupdate=180 htmlcgi="/nagios/cgi-bin" [backend_ndo2fs_1] [backend_merlinmy_1] [rotation_demo] maps="demo,Demo2:demo2" interval=15

Pour modifier les liens de Nagvis et quils pointent vers Centreon : Modifier les liens Nagvis

Installation de Centron 2.3.8 :


# # # # cd .. tar xvzf centreon-2.3.8.tar.gz cd centreon-2.3.8 ./install.sh -i -v

10

On arrive dans linstalleur Centreon, il faut accepter la licence et continuer :

11

Prcisez les rpertoires en x86_64 pour RRDs.pm, PEAR.php : - /usr/lib64/perl5/RRDs.pm /usr/share/pear/PEAR.php Sinon faite une recherche du chemin par la commande : Find / -name RRDs.pm
12

Pour ndomod ci-dessous, mettre cette ligne : /usr/local/nagios/bin/ndomod.o

13

14

Une fois linstallation effectue, Centreon vous invite vous rendre http://localhost/centreon

15

On fait next jusqu arriver la page :

16

Puis, on entre les paramtres ncessaires pour la configuration de la Database (Base de donne) : Modifiez le NDO Database Name par ndo, mettez le mme password que plus haut (pour le ndouser).

On remplit nos paramtres :

17

18

Configuration de centreon
Nous allons sur notre interface Centreon, onglet configuration, Centreon puis ndo2db.cfg , on clique sur central et on modifie comme le screenshot :

Puis le fichier ndomod.cfg comme suit :

19

Il ne reste plus qu aller dans configuration, Nagios, cochez toutes les cases et cliquez sur export. Voil, votre configuration est prte et fonctionnelle.

Utilisation dun relai SMTP pour les notifications Mail :


Liens vers larticle : Comment configurer un relais SMTP sur Sendmail?

Utilisation des Perf-data de Nagios


On vrifie que Censtorage rcupre les donnes avec cette commande :
Service cenststorage status

Si la commande ne renvoie rien tout est OK, mais si elle renvoie :


No lock file found in /var/run/centreon/centcored.pid

Alors il faut modifier le fichier :


/usr/local/centreon/bin/centstorage

Et modifier la ligne 48 :
#use lib=/usr/lib/

Par :
use lib=Chemun_RRDs

Pour avoir le Chemun_RRDs :


Find / -name RRDs.pm

Annexes
20

En cas de problme Mysql


Modification du fichier de configuration :
cp /etc/my.cnf /etc/my.cnf.old cp /usr/share/mysql/my-large.cnf /etc/my.cnf vi /etc/my.cnf

Dcommentez les lignes comme dans lexemple suivant :


# Uncomment the following if you are usingInnoDB tables #innodb_data_home_dir = /data/sgbd/ #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /data/sgbd/ #innodb_log_arch_dir = /data/sgbd/ # You canset .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high innodb_buffer_pool_size = 256M innodb_additional_mem_pool_size = 20M # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 64M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 # un fichier par table innodb innodb_file_per_table # Gestion des logs binaires (mysql-bin.0000X avec index mysql-bin.index) #Default 1G = 1073741824 #150Mo * 1024 * 1024 = 157286400 octets #60Mo * 1024 * 1024 = 62914560 octets #max_binlog_size=62914560 #Default 4Go = 4294967295 octets #1073741824 = 1Go #max_binlog_cache_size=1073741824 #expire_logs_days=1

Redmarrer la base de donnes (/etc/init.d/mysqld restart) et lancer le script de scurisation qui permet au passage dattribuer un mot de passe root.
[root@NOMSERVEURmysql]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, soyoushouldjustpress enter here. Enter current password for root (enter for none): OK, success fully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation

21

go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n ... skipping. By default, MySQL comeswith a databasenamed 'test' thatanyonecan access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removingprivileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effectimmediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!

Sauvegarde centreon
Sauvegarde tout les soirs. Un script excut par cron est lanc avant sauvegarde pour arrter les services et un autre pour les relancer la fin. Au passage du script darrt, un dump de la base de donnes est cr ainsi quune vrification et une optimisation de base.

Restaurer la base de donnes nagios


Reprendre les dumps sauvegards.
gunzip dmpinfo20090618.sql.gz dmpmysql20090618.sql.gz dmpnagios20090618.sql.gz mysql -u root -p < dmpmysql20090618.sql mysql -u root -p < dmpinfo20090618.sql mysql -u root -p < dmpnagios20090618.sql

Faire de mme avec les autres bases.

Rotation des logs


vi /etc/logrotate.d/services-nagios /var/log/nagios/*.log { daily rotate 1 size=1M compress dateext missingok notifempty

22

} /var/log/centreon/*.log { daily rotate 1 size=1M compress dateext missingok notifempty } /var/nagios/host-perfdata { daily rotate 1 size=1M compress ateext missingok notifempty }

23