tp_nagios

Upload: keltoum-sahlaoui

Post on 05-Apr-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 TP_Nagios

    1/19

    Gervais COQUIL

    Boris PASCAULT

    Licence Pro QSSI

    Groupe TP B

    N i

    30 novembre 2009

  • 7/31/2019 TP_Nagios

    2/19

    N i

    Installation de Nagios

    Afin dinstaller Nagios il est tout dabord ncessaire dinstaller certains composants :

    Un serveur web (nous utiliserions Apache) :

    yum install httpd

    Un compilateur C :

    yum install gcc

    Des librairies pour le compilateur :

    yum install glibc glibc-commonyum install gd gd-devel

    Il faut crer un nouvel utilisateur :

    su -l/usr/sbin/useradd -m nagiospasswd nagios

    Ainsi quun nouveau groupe contenant les utilisateurs nagios et apache :

    /usr/sbin/groupadd nagcmd/usr/sbin/usermod -a-G nagcmd nagios/usr/sbin/usermod -a-G nagcmd apache

  • 7/31/2019 TP_Nagios

    3/19

    Modification du fichier contacts.cfg

    vi/usr/local/nagios/etc/objects/contacts.cfg

    Dans le fichier ci-dessus nous avons paramtr le compte admin comme tant nagiosadmin et les messages derreur

    seront envoys sur la boite mail root@localhost.

    Compilation et Installation de linterface Web de Nagios :

    make install install-webconf

    Association du compte nagiosadmin celui permettant la connexion linterface web :

    htpasswd -c/usr/local/nagios/etc/htpasswd.users nagiosadmin

    Redmarrage de Apache :

    service httpd restart

    Extraction du paquet plugins

    define contact{

    contact_name nagiosadmin ; Short name of useruse generic-contact ; Inherit default values from

    generic-contact template (defined above)alias Nagios Admin ; Full name of user

    email root@localhost ;

  • 7/31/2019 TP_Nagios

    4/19

  • 7/31/2019 TP_Nagios

    5/19

    Configuration des htes

    Afin de pouvoir ajouter un fichier de configuration supplmentaire Nagios, il faut ajouter une ligne du style

    suivant :

    cfg_file=/usr/local/nagios/etc/objects/gervaisboris.cfg

    Dans le fichier /usr/local/nagios/etc/nagios.cfg

    Contenu du fichier gervaisboris.cfg concernant les htes :

    define host{use linux-serverhost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-

    Bastien, Profalias Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-

    Bastien, Profaddress 10.153.3.83}

    define host{use linux-server

    host_name Fabien-Charly

    alias Fabien-Charlyaddress 10.153.3.82}

    define host{use linux-serverhost_name Alexandre-Gaelalias Alexandre-Gael

    address 10 153 3 84

  • 7/31/2019 TP_Nagios

    6/19

    Ce qui donne sur linterface Web :

  • 7/31/2019 TP_Nagios

    7/19

    Extrait du fichier templates.cfg concernant les linux-server (linux-serverutilisant generic-host) :

    define host{name generic-host ; The name of this host templatenotifications_enabled 1 ; Host notifications are enabledevent_handler_enabled 1 ; Host event handler is enabledflap_detection_enabled 1 ; Flap detection is enabledfailure_prediction_enabled 1 ; Failure prediction is enabled

    process_perf_data 1 ; Process performance dataretain_status_information 1 ; Retain status information across program restartsretain_nonstatus_information 1 ; Retain non-status information across program restartsnotification_period 24x7 ; Send host notifications at any timeregister 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!}

    define host{

    name linux-server ; The name of this host templateuse generic-host ; This template inherits other values from the generic-host templatecheck_period 24x7 ; By default, Linux hosts are checked round the clockcheck_interval 5 ; Actively check the host every 5 minutesretry_interval 1 ; Schedule host check retries at 1 minute intervalsmax_check_attempts 10 ; Check each Linux host 10times(max)check_command check-host-alive ; Default command to check Linux hostsnotification_period workhours ; Linux admins hate to be woken up, so we only notify during the day

    ; Note that the notification_period variable is being overridden from; the value that is inherited from the generic-host template!

    notification_interval 120 ; Resend notifications every 2 hoursnotification_options d,u,r ; Only send notifications for specific host statescontact_groups admins ; Notifications get sent to the admins by default

    register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!}

  • 7/31/2019 TP_Nagios

    8/19

    Configuration des groupes

    Les groupes permettent de rassembler les htes de manire organise.

    Extrait du fichier groups.cfg :

    define hostgroup{hostgroup_name Linux_1 ; The name of the hostgroupalias Machines sous Linux (1) ;Long name of the groupmembers Julien-Bastien, Fabien-Charly ; Comma separated list of

    hosts that belong to this group}

    define hostgroup{hostgroup_name Linux_2 ; The name of the hostgroupalias Machines sous Linux (2) ;Long name of the groupmembers localhost, Alexandre-Gael, Alpha-Fiacre, Alexandre-Gael,

    Fabien-Charly, Julien-Bastien, Prof ; Comma separated list of hosts that belongto this group

    }

    define hostgroup{hostgroup_name Autre ; The name of the hostgroupalias Autres ;Long name of the groupmembers Prof ; Comma separated list of

    hosts that belong to this group}

    define hostgroup{hostgroup_name Portables ; The name of the hostgroupalias Portables sous Windows ; Long name of the groupmembers MiniNeuf, Tyrael ; Comma separated list of

    h t th t b l t thi

  • 7/31/2019 TP_Nagios

    9/19

    Ce qui donne sur linterface Web :

  • 7/31/2019 TP_Nagios

    10/19

    Configuration des services

    Pour les clients Linux :

    Test du PING vers lhte distant :

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description PINGcheck_command check_ping!100.0,20%!500.0,60%}

    Analyse de lespace disque restant (20% : ALERT, 10% WARNING) :

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description Root Partition

    check_command check_local_disk!20%!10

    %!/}

    Surveillance des utilisateurs connects (20 : ALERT, 50 WARNING) :

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description Current Userscheck_command check_local_users!20!50}

    Analyse du nombre de processus (250 : ALERT, 400 WARNING) :

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description Total Processescheck_command check_local_procs!250!400!RSZDT}

  • 7/31/2019 TP_Nagios

    11/19

    Analyse de la charge du systme:

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description Current Loadcheck_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0}

    Analyse de la charge du SWAP (20 : ALERT, 10 WARNING) :

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description Swap Usagecheck_command check_local_swap!20!10}

    Surveillance de la disponibilit du SSH (WARNING sur l arrt) :

    define service{use local-service ; Name of service template to use

    host_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description SSHcheck_command check_sshnotifications_enabled 0}

    Surveillance de la disponibilit du serveur Web (WARNING sur l arrt) :

    define service{use local-service ; Name of service template to usehost_name Alpha-Fiacre, Alexandre-Gael, Fabien-Charly, Julien-Bastien, Profservice_description HTTPcheck_command check_httpnotifications_enabled 0}

    Pour la description des templates voir la partie des clients Windows

  • 7/31/2019 TP_Nagios

    12/19

    Sur linterface Web :

  • 7/31/2019 TP_Nagios

    13/19

    Pour les clients Windows :

    Il est ncessaire dinstaller un agent SNMP, pour cela nous utiliserons NSClient++

    Il est aussi ncessaire de modifier le fichier command.cfg afin de tester certaines spcificits des clients Windows.

    # 'check_nt' command definitiondefine command{

    command_name check_ntcommand_line $USER1$/check_nt -H $HOSTADDRESS$-p12489-s jacky -v $ARG1$

    $ARG2$}

    Lattributjackycorrespond au groupe SNMP.

    Afin dassurer le bon fonctionnement de NSClient il faut activer le service correspondant.

    Sur le client Windows il faut paramtrer ladresse du client SNMP (ici notre poste Fedora avec Nagios) ainsi que le

    groupe, tout ceci ce fait dans le fichier : C:\Program Files\NSClient\NSC.ini

    [Settings];# OBFUSCATED PASSWORD

    ; This is the same as the password option but here you can store the password in anobfuscated manner.; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to thisfile can still figure out the; password. Its just a bit harder to do it at first glance.;obfuscated_password=Jw0KAUUdXlAAUwASDAAB;;# PASSWORD; This is the password (-s) that is required to access NSClient remotely. If you leave

    thi bl k ill b bl t th d tl

  • 7/31/2019 TP_Nagios

    14/19

    Fichier windows.cfg :

    Test du PING:

    define service{use local-servicehost_name Tyrael, MiniNeufservice_description PINGcheck_command check_ping!100.0,20%!500.0,60%}

    Test de la version de NSClient++:

    define service{use generic-servicehost_name Tyrael, MiniNeufservice_description NSClient++ Versioncheck_command check_nt!CLIENTVERSION}

    Test du temps depuis le dernier dmarrage:

    define service{use generic-servicehost_name Tyrael, MiniNeufservice_description Uptimecheck_command check_nt!UPTIME}

    Test de la charge CPU:

    d fi i {

  • 7/31/2019 TP_Nagios

    15/19

    Test de fonctionnement du serveur Web sous Windows :define service{

    use generic-servicehost_name Tyrael, MiniNeufservice_description W3SVCcheck_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC}

    Test de ltat du processus Explorer.exe :

    define service{use generic-servicehost_name Tyrael, MiniNeufservice_description Explorercheck_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe}

    On utilise le template local-service pour le PING et generic-service pour tout ce qui concerne Windows.

  • 7/31/2019 TP_Nagios

    16/19

    Dtails des services dans templates.cfg :

    define service{name generic-service ; The 'name' of this service templateactive_checks_enabled 1 ; Active service checks are enabledpassive_checks_enabled 1 ; Passive service checks are enabled/acceptedparallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major

    performance problems)

    obsess_over_service 1 ; We should obsess over this service (if necessary)check_freshness 0 ; Default is to NOT check service 'freshness'notifications_enabled 1 ; Service notifications are enabledevent_handler_enabled 1 ; Service event handler is enabledflap_detection_enabled 1 ; Flap detection is enabledfailure_prediction_enabled 1 ; Failure prediction is enabledprocess_perf_data 1 ; Process performance dataretain_status_information 1 ; Retain status information across program restartsretain_nonstatus_information 1 ; Retain non-status information across program restartsis_volatile 0 ; The service is not volatilecheck_period 24x7 ; The service can be checked at any time of the daymax_check_attempts 3 ; Re-check the service up to 3timesin order to determine its final (hard) statenormal_check_interval 10 ; Check the service every 10 minutes under normal conditions

    retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determinedcontact_groups admins ; Notifications get sent out to everyone in the 'admins' groupnotification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events

    notification_interval 60 ; Re-notify about service problems every hournotification_period 24x7 ; Notifications can be sent out at any timeregister 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!}

    define service{name local-service ; The name of this service templateuse generic-service ; Inherit default values from the generic-service definition

    max_check_attempts 4 ; Re-check the service up to 4timesin order to determine its final (hard) state

    normal_check_interval 5;Check the service every 5 minutes under normal conditionsretry_check_interval 1 ; Re-check the service every minute until a hard state can be determined

    register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!}

  • 7/31/2019 TP_Nagios

    17/19

    Configuration des switchs

    Plugin que nous avons utilis pour tester les interfaces du Switch (Cisco Catalyst 2960) :

    #!/bin/sh

    # Paramtres :# $1 : Adresse Ip de l'adresse de l'hte tester# $2 : Numro de l'interface tester# 1=FastEthernet0,# 2=Serial0,# 3=Serial1,

    # 4=Null,

    # Definition des valeurs de retour possibles

    OK=0WARNING=1CRITICAL=2UNKNOWN=3

    # Test de la syntaxe de l'appel du plugin

    if[$#-ne 2];then# Affichage d'un message d'erreurecho"Usage : $0 "echo""echo"1 = FastEthernet0"echo"2 = Serial0"echo"3 = Serial1"

    h "4 ll"

  • 7/31/2019 TP_Nagios

    18/19

    define host{use generic-switch ; Inherit default values from a templatehost_name Cisco Catalyst 2960 ; The name we\'re giving to this switchalias Cisco Catalyst 2960 ; A longer name associated with the switchaddress 10.153.3.100 ; IP address of the switchhostgroups switches ; Host groups this switch is associated with}

    define hostgroup{hostgroup_name switches ; The name of the hostgroupalias Network Switches ; Long name of the group}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Uptimecheck_command check_snmp!-C public -o sysUpTime.0}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960 ; The name of the host the service is associated withservice_description PING ; The service descriptioncheck_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the servicenormal_check_interval 5 ; Check the service every 5 minutes under normal conditionsretry_check_interval 1 ; Re-check the service every minute until its final/hard state is

    determined}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 1 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.1 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 2 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.2 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a template

  • 7/31/2019 TP_Nagios

    19/19

    host_name Cisco Catalyst 2960service_description Port 3 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.3 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 4 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.4 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 5 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.5 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 6 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.6 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 7 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.7 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960

    service_description Port 8 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.8 -r1-m RFC1213-MIB}

    define service{use generic-service ; Inherit values from a templatehost_name Cisco Catalyst 2960service_description Port 9 Link Statuscheck_command check_snmp!-C public -o ifOperStatus.9 -r1-m RFC1213-MIB}