Installation Nagios sur Centos 5
Installation des paquets
nécessaires :
       #yum install httpd gcc glibc glibc-common gd gd-devel php
Création du User compte
et Group :
#useradd -m nagios
        #groupadd
nagcmd
        #usermod
-a -G nagcmd nagios
#usermod -a -G nagcmd apache
Création d’un répertoire
pour sauvegarder les fichiers d’installation de Nagios :
       
#mkdir /opt/Nagios
Téléchargement de Nagios
et Plugins :
Sauvegarder les fichiers dans le reperatoire /opt/Nagios
Pour les versions Nagios 3.0.6 (Stable) et Nagios Plugins 1.4.13 (Stable)
Extraction des fichiers :
       
#cd /opt/Nagios
#tar xzf nagios-3.0.6.tar.gz
#cd nagios-3.0.6
Compilation et
configuration de Nagios :
#./configure --with-command-group=nagcmd
Compilation de Nagios:
       
#make all
#make all
Compiler les
fichiers binaires, init scripts, les fichiers de config:
#make install
#make install-init
#make install-config
#make install-commandmode
** Ne démarrez pas Nagios ** 
Nagios est maintenant
installé dans le répertoire /usr/local/nagios/
Installer interface web
de Nagios:
#make install-webconf
Nagios Interface Web installée
dans /usr/local/nagios/share (fichier conf http ajouté au fichier
/etc/httpd/conf.d/nagios.conf)
Créer un utilisateur
pour connecter à l'interface Web:
Nous allons créer l'utilisateur
"nagiosadmin" (souvenez-vous du mot de passe que vous attribuez)
      #htpasswd -c /usr/local/nagios/etc/htpasswd.users
nagiosadmin
Redémarrez Apache:
      #service httpd restart
Install Nagios
Plugins :
Extraction des fichiers :
      #cd /opt/Nagios
      #tar xzf nagios-plugins-1.4.13.tar.gz
      #cd nagios-plugins1.4.13
Compilation et Configuration Nagios Plugins :
#./configure --with-nagios-user=nagios --with-nagios-group=nagios
      #make
      #make
install
Configuration d’adresse email nagiosadmin pour les alerts:
#vi /usr/local/nagios/etc/objects/contacts.cfg
email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
Vérifiez les fichiers
d'exemples de configuration de Nagios :
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
Démarrer Nagios :
           
Activer Nagios pour commencer au démarrage du système /boot
#chkconfig --add nagios
      #chkconfig
nagios on
#chkconfig httpd on
          
Démarrer Nagios :
#service nagios start
      #chcon
-R  -t httpd_sys_content_t /usr/local/nagios
Connectez-vous à
l'interface Web:
Surveiller vos serveurs Windows avec Nagios
Dans la longue série des billets sur Nagios, en voici un tout spécialement dédié aux lecteurs qui ont à administrer des machines sous Windows. Nous allons décrire l'installation de NSClient, un plugin permettant de récupérer un nombre important de d'informations à surveiller sur une machine Windows.
Comme le plugin NRPE, NSClient se base sur une architecture client/serveur. La partie cliente (nommée check_nt), doit être disponible sur le serveur Nagios. La partie serveur (NSClient++) est à installer sur chacune des machines Windows à surveiller.
Installation de NSClient++ sur
machine Windows a surveillée :
Télécharger la dernière version (Soit 64bit ou 32bit) à l'adresse
suivante :
Installer NSClient++
Dans l’espace « Allowed Hosts » mettre l’adresse IP de serveur
Nagios et Spécifier le mot de passe qu’il faut utilise pour configure Nagios
après
Apres l’installation :
Clique droite sur Ordinateur – Gérer – Services – (Clique droite
NSClient++) et cocher « Autoriser le service à interagir avec le
bureau »
 (1) Editer le fichier « nsclientNSC.INI » (C:\Program
Files\NSClient++\) :
Modifier le dossier C:\Program Files\NSClient + +\fichier NSC.ini et
décommenter [modules] sauf RemoteConfiguration.dll et CheckWMI.dll
| 
[modules] 
;#NSCLIENT++
  MODULES 
;#A list
  with DLLs to load at startup. 
; 
  You will need to enable some of these for NSClient++ to work. 
; ! ! ! !
  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 
;
  *                                                              
  * 
; * N O T
  I C E ! ! ! - Y O U   H A V E   T O   E D I
  T   T H I S * 
;
  *                                                              
  * 
; ! ! ! !
  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 
FileLogger.dll 
CheckSystem.dll 
CheckDisk.dll 
NSClientListener.dll 
NRPEListener.dll 
SysTray.dll 
CheckEventLog.dll 
CheckHelpers.dll 
;CheckWMI.dll 
; 
;RemoteConfiguration
  IS AN EXTREM EARLY IDEA SO DONT USE FOR PRODUCTION ENVIROMNEMTS! 
;RemoteConfiguration.dll 
;NSCA
  Agent is a new beta module use with care! 
NSCAAgent.dll 
;LUA
  script module used to write your own "check deamon" (sort of) early
  beta. 
LUAScript.dll 
;Script to
  check external scripts and/or internal aliases, early beta. 
CheckExternalScripts.dll 
;Check
  other hosts through NRPE extreme beta and probably a bit dangerous!  
NRPEClient.dll | 
(2) Modifier « NSC.ini » et décommenter allowed_hosts. Modifier le
dossier C:\Program Files\NSClient++\fichier NSC.ini et Décommenter allowed_host dans
les paramètres et ajouter l'adresse IP du serveur nagios.
| 
;# ALLOWED
  HOST ADDRESSES 
; 
  This is a comma-delimited list of IP address of hosts that are allowed to
  talk to the all daemons. 
;  If
  leave this blank anyone can access the deamon remotly (NSClient still
  requires a valid password). 
; 
  The syntax is host or ip/mask so 192.168.0.0/24 will allow anyone on that
  subnet access 
allowed_hosts=192.168.1.2/255.255.255.0 | 
(3) Modifier « NSC.ini » et décommenter le port. Modifier le
dossier C:\Program Files\NSClient++\fichier NSC.ini et décommenter le
port # sous [NSClient] section:
| 
;#
  NSCLIENT PORT NUMBER 
; 
  This is the port the NSClientListener.dll will listen to. 
port=12489 | 
(4) Sauvegarder le fichier « NSC.ini » et Démarrez le service NSClient++
les étapes de configuration du serveur Nagios pour
surveillance windows machine :
Vérifiez « check_nt » commande
et windows-server template :
Vérifiez que « check_nt » est activé dans
/usr/local/nagios/etc/objects/commands.cfg
| 
#
  'check_nt' command definition 
define
  command{ 
command_name   
  check_nt 
command_line   
  $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 –s(le mot de passe du
  NSClient++) -v $ARG1$ $ARG2$ 
} | 
Vérifiez que le modèle windows-server est activé dans
/usr/local/nagios/etc/objects/templates.cfg :
| 
# Windows
  host definition template - This is NOT a real host, just a template! 
define
  host{ 
name                   
  windows-server  ; The name of this host template 
use                    
  generic-host    ; Inherit default values from the generic-host
  template 
check_period           
  24x7            ; By
  default, Windows servers are monitored round the clock 
check_interval         
  5              
  ; Actively check the server every 5 minutes 
retry_interval         
  1              
  ; Schedule host check retries at 1 minute intervals 
max_check_attempts     
  10   
            ; Check each
  server 10 times (max) 
check_command          
  check-host-alive        ; Default command
  to check if servers are "alive" 
notification_period    
  24x7            ; Send
  notification out at any time - day or night 
notification_interval
    30             
  ; Resend notifications every 30 minutes 
notification_options   
  d,r             ;
  Only send notifications for specific host states 
contact_groups         
  admins          ; Notifications
  get sent to the admins by default 
hostgroups      
         windows-servers ; Host groups that
  Windows servers should be a member of 
register               
  0              
  ; DONT REGISTER THIS - ITS JUST A TEMPLATE 
} | 
Décommentez windows.cfg dans
/usr/local/nagios/etc/nagios.cfg 
| 
#
  Definitions for monitoring a Windows machine 
cfg_file=/usr/local/nagios/etc/objects/windows.cfg | 
Modifier /usr/local/nagios/etc/objects/windows.cfg
| 
# Define a
  host for the Windows machine we'll be monitoring 
# Change
  the host_name, alias, and address to fit your situation 
define
  host{ 
use            
  windows-server             
  ; Inherit default values from a template 
host_name  
  remote-windows-host      ; The name we're giving to
  this host 
alias           
  Remote Windows Host     ; A longer name associated with
  the host 
address      
  (adresse IP du machine a
  surveillé)   ; IP address of the remote
  windows host 
} | 
Remarque :
Pour ajouter une autre ou plusieurs machines windows à Nagios, il suffit de
copier le code et coller, changer le « host_name » pour connaitre la
machine. ( ajouter les services pour cette machine)
Définir les services de Windows
qui doivent être surveillés
Voici les services par défaut des fenêtres qui sont déjà
activés dans le « windows.cfg ». Assurez-vous de
mettre à jour l'host_name sur ces services afin de
refléter les host_name définie dans l'étape ci-dessus.
| 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  NSClient++ Version 
check_command          
  check_nt!CLIENTVERSION 
} 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  Uptime 
check_command          
  check_nt!UPTIME 
} 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  CPU Load 
check_command          
  check_nt!CPULOAD!-l 5,80,90 
} 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  Memory Usage 
check_command          
  check_nt!MEMUSE!-w 80 -c 90 
} 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  C:\ Drive Space 
check_command          
  check_nt!USEDDISKSPACE!-l c -w 80 -c 90 
} 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  W3SVC 
check_command          
  check_nt!SERVICESTATE!-d SHOWALL -l W3SVC 
} 
define
  service{ 
use                    
  generic-service 
host_name              
  remote-windows-host 
service_description    
  Explorer 
check_command          
  check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe 
} | 
Vérification de la
configuration et redémarrer Nagios.
Vérifiez la configuration du Nagios, comme indiqué ci-dessous :
| 
[nagios-server]#
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 
Total
  Warnings: 0 
Total
  Errors:   0 
Things
  look okay - No serious problems were detected during the pre-flight check | 
Redemarrer Nagios.
| 
[nagios-server]#
  /etc/rc.d/init.d/nagios stop 
Stopping
  nagios: .done. 
[nagios-server]#
  /etc/rc.d/init.d/nagios start 
Starting
  nagios: done. | 
Vérifiez l'état des différents services fonctionnant sur l'hôte
distant Windows à partir de l'interface web Nagios (http://(adresse
IP de machine)/nagios) comme indiqué ci-dessous :








 
 
No comments:
Post a Comment