[FreeBSD] Installation et configuration de Nagios / Centreon

----------------------------------------------------------------------------------
- Installation et configuration de Centreon sur FreeBSD
-----------------------------------------------------------------------------------
------------ Auteur : Rémi LAURENT -----------------------------------
------------ Mail : cloud@madpowah.org -------------------------------
------------ Date : 26/05/2008 ----------------------------------
-----------------------------------------------------------------------------------

Aujourd'hui je me suis amusé a tester Nagios puis Centreon. L'installation de Nagios s'est passé niquel depuis les ports. J'ai juste eu a reconfigurer les sample de /usr/local/etc/nagios en .cfg et a modifier Apache en mettant dans le httpd.conf

<Directory /usr/local/www/nagios>
     Order deny,allow
     Deny from all
     Allow from 127.0.0.1
</Directory>

 <Directory /usr/local/www/nagios/cgi-bin>
     AllowOverride AuthConfig
     Options ExecCGI
   </Directory>

   ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
   Alias /nagios/ /usr/local/www/nagios/
On crée ensuite le .htaccess et le .htpasswd dans /usr/local/www/nagios/cgi-bin/ et ca roule.

Pour Centreon, c'est une autre histoire vu qu'il n'est pas dans les ports :)

Donc j'ai commencé par télécharger la version 1.4.26 depuis le site de Centreon. J'ai bien sur lu le INSTALL et installé tous les packages nécessaires. Ensuite j'ai exécuté le fichier d'install :
./install.sh
La commence la série de questions de Centreon ou j'ai du donner quelques coup de find et whereis pour voir ou étaient mes fichiers. Voila l'install :
###############################################################################
#                            Centreon (www.centreon.com)                      
#
#                            Thanks for using Centreon                        
#
#                                                                             
#
#                                   v 1.4.2.6                                 
#
#                                                                             
#
#                             infos@oreon-project.org                         
#
#                                                                             
#
#                     Make sure you have installed and configured             
#
#                                   sudo - sed                                
#
#                          php - apache - rrdtool - mysql                     
#
#                                                                             
#
#                                                                             
#
###############################################################################
#                                 The Team Centreon                           
#
###############################################################################

 WARNING : Setup will delete all previous informations in your Centreon 
DATABASE.

Are you sure to continue ?
[y/n], default to [n]:y
Where is installed Nagios ?
default to [/usr/local/nagios]:/usr/local/www/nagios

Where is your nagios etc directory ?
default to [/usr/local/www/nagios/etc]:/usr/local/etc/nagios
Path /usr/local/etc/nagios                                 OK

Where is your nagios var directory ?
default to [/usr/local/www/nagios/var]:/var/spool/nagios
Path /var/spool/nagios                                     OK

Where is your nagios plugins (libexec) directory ?
default to [/usr/local/www/nagios/libexec]:/usr/local/libexec/nagios
Path /usr/local/libexec/nagios                             OK

Where is your nagios bin directory?
default to [/usr/local/www/nagios/bin]:/usr/local/bin
Path /usr/local/bin                                        OK

Where is your nagios image directory ?
default to 
[/usr/local/www/nagios/share/images]:/usr/local/www/nagios/images
Path /usr/local/www/nagios/images                          OK

Where do I install centreon ?
default to [/usr/local/centreon]:
Directory /usr/local/centreon does not exits.              CRITICAL

Do you want me to create this directory [/usr/local/centreon]?[Y/n]y  
Path /usr/local/centreon                                   OK

Where is sudo configuration file?
default to [/etc/sudoers]:/usr/local/etc/sudoers
File /usr/local/etc/sudoers                                OK

Where is installed RRD perl modules [RRDs.pm] ?
Just put directory, not full path.
default to 
[/usr/local/rrdtool/lib/perl]:/usr/local/lib/perl5/site_perl/5.8.8/mach/
File /usr/local/lib/perl5/site_perl/5.8.8/mach/            OK

Where is rrdtool binary ?
default to [/usr/bin/rrdtool]:/usr/local/bin/rrdtool
/usr/local/bin/rrdtool                                     OK

Where is mail binary ?
default to [/usr/bin/mail]:/usr/bin/mail
/usr/bin/mail                                              OK

Where is PEAR Path ?
default to [/usr/share/pear]:/usr/local/share/pear/
PEAR Path /usr/local/share/pear                            OK

------------------------------------------------------------------------
                           User Management
------------------------------------------------------------------------


Finding Apache group :
Finding Apache user :
Finding Nagios group :                                     nagios
Finding nagios group 'nagios' in /etc/group                YES
Finding Nagios user :                                      nagios
Finding nagios user 'nagios' in /etc/passwd                YES

------------------------------------------------------------------------
                              Other Stuff
------------------------------------------------------------------------


TrueType directory created                                 OK
TrueType verdana installed                                 OK
Finding PEAR Path : /usr/local/share/pear                  OK
PEAR Font directory created                                OK
PEAR Font installed                                        OK

------------------------------------------------------------------------
                        Configure Apache server
------------------------------------------------------------------------


Create '/oreon.conf'                                       OK
Configuring Apache                                         OK
Couldn't add  to nagios group                              WARNING
Unable to restart apache server                            WARNING

------------------------------------------------------------------------
                              Start Centreon Installation
------------------------------------------------------------------------


Centreon Directory already exists                          PASSED
Copy 'filesGeneration'                                     OK
Copy 'filesUpload'                                         OK
Copy 'GPL_LIB'                                             OK
Copy 'log'                                                 OK
Copy 'www'                                                 OK
Copy 'cron'                                                OK
Copy 'ODS'                                                 OK
Copy 'ODS_SRC_ETC'                                         OK
Copy 'doc'                                                 OK

------------------------------------------------------------------------
                   Start Plugins Centreon Installation
------------------------------------------------------------------------


/usr/local/libexec/nagios already exists                   PASSED

Preparing Oreon Plugins...
  -> centreon.conf                                         OK
  -> centreon.pm                                           OK 
  -> check_centreon_MS_multiple_services                   OK
  -> check_centreon_dummy                                  OK
  -> check_centreon_nt                                     OK
  -> check_centreon_ping                                   OK
  -> check_centreon_snmp_IF_adminstatus                    OK
  -> check_centreon_snmp_TcpConn                           OK
  -> check_centreon_snmp_cpu                               OK
  -> check_centreon_snmp_loadaverage                       OK
  -> check_centreon_snmp_multiple_process                  OK
  -> check_centreon_snmp_packetErrors                      OK
  -> check_centreon_snmp_packetLost                        OK
  -> check_centreon_snmp_process                           OK
  -> check_centreon_snmp_process_detailed                  OK
  -> check_centreon_snmp_remote_storage                    OK
  -> check_centreon_snmp_traffic                           OK
  -> check_centreon_snmp_uptime                            OK
  -> check_centreon_snmp_value                             OK
  -> check_meta_service                                    OK
  -> check_snmp_cpfw.pl                                    OK
  -> check_snmp_load.pl                                    OK
  -> check_snmp_mem.pl                                     OK
  -> check_snmp_process.pl                                 OK
  -> check_snmp_processus_loaded.pl                        OK
  -> check_snmp_script_result.pl                           OK
  -> check_snmp_storage.pl                                 OK
  -> check_snmp_win.pl                                     OK

  -> process-service-perfdata                              OK
  -> submit_host_check_result                              OK
  -> submit_service_check_result                           OK

Do you want to install Centreon Plugins ?

[y/n], default to [y]:y
Installing Centreon Plugins on '/usr/local/libexec/nagios' OK
chown: root.nagios: Invalid argument

------------------------------------------------------------------------
                     Start Traps Handler Installation
------------------------------------------------------------------------



Preparing Oreon Plugins...
-> fill_trapDB
-> genSnmpttConfFile
-> trapHandler

Do you want to install Centreon Traps Plugins ?
  
[y/n], default to [y]:
Installing Centreon Traps Plugins on
/usr/local/libexec/nagios/traps created                    OK
  
Where is your SNMP configuration file?
default to [/etc/snmp/]:/etc
  
Moving snmptrapd.conf to /etc                              OK
/etccentreon_traps created                                 OK
Moving snmptt.ini to /etccentreon_traps/                   OK
Moving snmp.conf to /etc                                   OK
chown: .nagios: Invalid argument
Moving snmptt to /usr/sbin/                                OK
Moving snmpttconvertmib to /usr/sbin/                      OK
/usr/local/libexec/nagios/traps/'                          OK
  
  
Finding Centreon Plugins configuration file 'centreon.conf'OK
You already seem to have installed the plugins Centreon.
Do you want overwrite this file ? You must regenerate this one from 
Centreon interface.
[y/n], default to [n]:n
/usr/local/centreon/filesGeneration/nagiosCFG already existPASSED
/usr/local/centreon/filesUpload/nagiosCFG already exists   PASSED
  
------------------------------------------------------------------------
                       Start ODS Installation
------------------------------------------------------------------------
  

Checking ODS data folder :
Creating Centreon Directory '/var/lib/ods'                 OK
Checking ODS database folder :
Creating Centreon Directory '/var/lib/ods/database/'       OK
Checking ODS log folder :
Creating Centreon Directory '/var/log/ods/'                OK
Replace ODS Macro                                          OK
Install ODS Binary                                         OK
Set ODS properties                                         OK
functions: line 583: /etc/init.d/ods: No such file or directory
chmod: /etc/init.d/ods: No such file or directory

------------------------------------------------------------------------
                    Replace Macro In ODS cron script
------------------------------------------------------------------------


in /usr/local/centreon/cron/inventory_update.php           OK
in /usr/local/centreon/cron/reporting/ArchiveLogInDB.php   OK
in /usr/local/centreon/cron/parsing_status.pl              OK
in /usr/local/centreon/cron/parsing_log.pl                 OK

------------------------------------------------------------------------
                       Start Centreon Cron Configuration
------------------------------------------------------------------------
  

Specify user do you use for Centreon cron
Default to [nagios]
crontab: no crontab for nagios
You old crontab is backup on /tmp/crontab_nagios.55tnky file

------------------------------------------------------------------------
                            Configure Sudo
------------------------------------------------------------------------
  

Sorry, we doesn't found nagios init script                 PASSED
Which is your nagios init script ?
default is [/etc/init.d/nagios2]:/usr/local/etc/rc.d/nagios

Configuring Sudo                                           OK
  
------------------------------------------------------------------------
                          Centreon Post Install
------------------------------------------------------------------------
  

Finding mail binary : /usr/bin/mail                        OK
Finding rrdtool binary : /usr/local/bin/rrdtool            OK
Create /usr/local/centreon/www/install/installoreon.conf.phOK
Create /etc/oreon.conf                                     OK
Configuring Oreon post-install                             OK

###############################################################################
#      Go to the URL : http://your-server/oreon/                              
#
#                   or http://your-server/centreon/  to finish the setup      
#
#                                                                             
#
#                    Report bugs at bugs@oreon-project.org                    
#
#                                                                             
#
#                           Thanks for using Centreon.                        
#
#                             -----------------------                         
#
#                        Contact : infos@oreon-project.org                    
#
#                            http://www.centreon.com                          
#
###############################################################################
Voila l'installation est maintenant terminée.

On va modifier notre httpd.conf pour pouvoir lancer Centreon :
Alias /centreon/ /usr/local/centreon/www/
<Directory /usr/local/centreon/www/>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
</Directory>

Je donne les droits nécessaires pour finir l'installation :
chown -R www:nagios /usr/local/etc/nagios/
chown -R www:nagios /usr/local/libexec/nagios
chmod -R 775 /usr/local/libexec/nagios
chmod -R 775 /usr/local/etc/nagios/
chmod -R 775 /usr/local/centreon/ODS/
chown -R www:www /usr/local/centreon/ODS
chown -R www:www /usr/local/centreon/www
chmod -R 775 /usr/local/centreon/www

Je vais avoir besoin de packages PEAR donc je les installe direct avec la commande :
pear install -o -f --alldeps DB DB_DataObject DB_DataObject_FormBuilder 
MDB2 Date Numbers_Roman Numbers_Words HTML_Common HTML_QuickForm
HTML_QuickForm_advmultiselect HTML_Table Auth_SASL HTTP Image_Canvas 
Image_Color Image_Graph Image_GraphViz Mail Mail_Mime Net_SMTP Net_Socket 
Net_Traceroute
Net_Ping Validate XML_RPC SOAP

Hop une fois tout cela fini on va sur la page http://127.0.0.1/centreon/ pour finir l'installation. La on donne les bons chemins, utilisateurs MySQL, pas besoin de faire un cours la dessus

Une fois tout cela terminé, il ne reste plus qu'a retourner sur http://127.0.0.1/centreon/ et a se logger.

Chanceux comme je suis ca n'a pas marché donc je me suis ajouté un utilisateur a la main.
Pour cela il faut aller dans la base centreon et dans la table contact. On ajoute un utilisateur avec un login, un alias (c'est lui qui sert de login), un mot de pass encrypté en MD5, et on met tout ce dont on a besoin a 1 (admin, enabled...)

On retente de se logger... Perso ca a encore foiré ... J'ai eu un DB insufficient permission.

On ne s'enerve pas et on va verifier les login et mot de pass dans les fichiers de conf :
- /usr/local/centreon/ODS/etc/conf.pm
- /usr/local/centreon/www/oreon.conf.php

La on met les bon logins et mot de pass mysql :)

Ouf ouf, on relance tout ca et miracle on arrive a se logger !

Maintenant il faut utiliser cet engin.

On commence par aller dans host, on ajoute un host, puis dans Service on ajoute ce que l'on veut exécuter comme commande et sur quel host.
Une fois cela fait, on va dans configuration > nagios > exporter, on coche tout les case du bas (4) et on choisi de restart Nagios. Perso il faut souvent que je restart a la main pour que ca marche vraiment. Et hopla tout marche par miracle :D

Allez bon courage a vous et j'espere que cela aidera du monde.