Tutoriel DNS dynamique sous Linux

[INSTALL] Nagios 3.5.1 - Configuration


Dans ce tutoriel, je vais superviser un serveur Windows, un poste client Windows et une imprimante.
Je souhaite superviser la RAM, le CPU et l'espace disque de mon serveur.
Je souhaite superviser les requêtes ICMP de mon poste client ainsi que la version de mon agent.
Je souhaite superviser le taux de toner dans mon imprimante. 


Deuxième partie d'un tutoriel - Configuration d'un serveur de supervision avec Nagios.
La première partie concernait l'installation d'un serveur de supervision avec Nagios (lien).
La troisième partie concernera le couplage avec Nagvis.


1. Ingrédients


- Debian 7 - Wheezy
- Nagios installé
- 13 minutes
- Poste client
- Serveur
- Imprimante

--------

Serveur Windows :
- Adresse IP : 192.168.1.250 /24
- OS : Windows Serveur 2012
- Nom : serv-test

Poste Windows :
- Adresse IP : 192.168.1.5 /24
- OS : Windows 7
- Nom : poste-test

Imprimante :
- Adresse IP : 192.168.1.71 /24
- Marque : HP
- Modèle : LaserJet 4700
- Nom : imp-nb-rdc

2. Classement des hôtes


Séparation des fichiers de conf des serveurs, des postes et des imprimantes. Je crée 3 répertoires :
cd /usr/local/nagios/etc


mkdir hotes_windows
mkdir serveurs_windows
mkdir imprimantes
Déclaration des dossiers auprès de Nagios :
nano /usr/local/nagios/etc/nagios.cfg
J'ajoute ces 3 lignes, elles indiquent à Nagios qu'il faut zieuté dans ces répertoires :
cfg_dir=/usr/local/nagios/etc/hotes_windows
cfg_dir=/usr/local/nagios/etc/serveurs_windows
cfg_dir=/usr/local/nagios/etc/imprimantes
Création des fichiers de conf correspondant aux différents hôtes :
cd /usr/local/nagios/etc/serveurs_windows
touch serv-test.cfg


cd /usr/local/nagios/etc/hotes_windows
touch poste-test.cfg


cd /usr/local/nagios/etc/imprimantes
touch imprimante1.cfg

3. Configuration des hôtes

3.1 Agent


Avant toute configuration, il est nécessaire d'installer un agent sur les hôtes Windows, dans mon cas j'utilise NSClient++.
Voici l'installation et la configuration de cet agent version 0.4.1.105.





Mais d'où vient ce mot de passe ?

Ce mot de passe est à déclarer dans le fichier "commands.cfg". Il permet de faire la synchro entre l'agent et le serveur nagios tout en apportant une pointe de sécurité :
# 'check_nt' command definition
define command{
        command_name    check_nt
        command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489  -s !Azerty -v $ARG1$ $ARG2$
        }

3.2 Configuration du serveur Windows


nano /usr/local/nagios/etc/serveurs_windows/serv-test.cfg 
# HOST DEFINITIONS

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       serv-test       ; The name we're giving to this host
        alias           serveur         ; A longer name associated with the host
        address         192.168.1.250   ; IP address of the host
        }

# HOST GROUP DEFINITIONS

define hostgroup{
        hostgroup_name  windows-servers ; The name of the hostgroup
        alias           Windows Servers ; Long name of the group
  }
# SERVICE DEFINITIONS

define service{
        use                     generic-service
        host_name               serv-test
        service_description     CPU Load
        check_command           check_nt!CPULOAD!-l 5,80,90
        }

define service{
        use                     generic-service
        host_name               serv-test
        service_description     Memory Usage
        check_command           check_nt!MEMUSE!-w 80 -c 90
        }

define service{
        use                     generic-service
        host_name               serv-test
        service_description     C:\ Drive Space
        check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
        }

3.3 Configuration du poste client Windows


nano /usr/local/nagios/etc/hotes_windows/poste-test.cfg 
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# 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       poste-test     ; The name we're giving to this host
        alias           poste          ; A longer name associated with the host
        address         192.168.1.5    ; IP address of the host
        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Create a service for monitoring ICMP
# Change the host_name to match the name of the host you defined above

define service{
        use                 generic-service
        host_name           poste-test
        service_description PING
        check_command       check_ping!100.0,20%!500.0,60%
        }


# Create a service for monitoring version of NSClient++
# Change the host_name to match the name of the host you defined above

define service {
        use                 generic-service
        host_name           poste-test
        service_description NSClient++ Version
        check_command       check_nt!CLIENTVERSION
}



3.4 Configuration de l'imprimante


nano /usr/local/nagios/etc/imprimantes/imprimante1.cfg 
###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the printer we'll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
        use             generic-printer  ; Inherit default values from a template
        host_name       imp-nb-rdc       ; The name we're giving to this printer
        alias           nb-rdc           ; A longer name associated with the printer
        address         192.168.1.71     ; IP address of the printer
        hostgroups      network-printers ; Host groups this printer is associated with
        }

###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################

# A hostgroup for network printers

define hostgroup{
        hostgroup_name  network-printers        ; The name of the hostgroup
        alias           Network Printers        ; Long name of the group
        }

###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################

# Create a service for monitoring the status of the printer
# Change the host_name to match the name of the host you defined above
# If the printer has an SNMP community string other than "public", change the check_command directive to reflect that

define service{
        use                     generic-service   
        host_name               imp-nb-rdc        
        service_description     Printer Status    
        check_command           check_hpjd!-C public  
        normal_check_interval   10      
        retry_check_interval    1       
        }

define service{
        use                     generic-service
        host_name               imp-nb-rdc
        service_description     Printer Status
        check_command           check_snmp_printer!public!"STATUS"
        }

define service{
        use                     generic-service
        host_name               imp-nb-rdc
        service_description     Toner Status
        check_command           check_snmp_printer!public!"CONSUM ALL"!5!2
        }

define service{
        use                     generic-service
        host_name               imp-nb-rdc
        service_description     Toner Supply
        check_command           check_snmp_printer!public!"CONSUM Toners"!20!10
}
Test de la configuration :
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
S'il n'y a aucune erreur, redémarrez Nagios :
service nagios restart

4. Test en image


Allez sur l'interface graphique de Nagios, dans le menu "Host", vous pouvez apercevoir vos 3 hôtes :
192.168.1.253\nagios
Clique sur l'image pour agrandir !


0 commentaires :

Enregistrer un commentaire