MONITORING - Installation Nagios 3.0.6 sur Corni
De PedroWiki
Sommaire
Introduction
Article "bloc-note" sur l'installation de Nagios 3.0.6 sur Corni.peaudeau.fr.
But du Nagios: surveillance des services sur r14493.ovh.net, a.k.a rps.pedrono.fr.
Installation
Guide d'installation
Installation Nagios 3.x - Ubuntu quickstart
Téléchargement de Nagios
jules@corni:/home/jules/$ wget http://switch.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz jules@corni:/home/jules/$ tar xvzf nagios-3.0.6.tar.gz jules@corni:/home/jules/$ wget http://puzzle.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz jules@corni:/home/jules/$ tar xvzf nagios-plugins-1.4.13.tar.gz
Vérification des prérequis
jules@corni:/home/jules/nagios-3.0.6$ dpkg -l|grep gcc jules@corni:/home/jules/nagios-3.0.6$ dpkg -l|grep build jules@corni:/home/jules/nagios-3.0.6$ sudo apt-get update jules@corni:/home/jules/nagios-3.0.6$ sudo apt-get install build-essential jules@corni:/home/jules/nagios-3.0.6$ sudo apt-cache search gd2 jules@corni:/home/jules/nagios-3.0.6$ sudo apt-get install libgd2-xpm-dev
Gestion des droits utilisateurs
jules@corni:/home/jules/nagios-3.0.6$ sudo useradd -m nagios jules@corni:/home/jules/nagios-3.0.6$ sudo passwd nagios Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully jules@corni:/home/jules/nagios-3.0.6$ jules@corni:/home/jules/nagios-3.0.6$ sudo usermod -G nagios nagios jules@corni:/home/jules/nagios-3.0.6$ sudo groupadd nagcmd jules@corni:/home/jules/nagios-3.0.6$ sudo usermod -a -G nagcmd nagios jules@corni:/home/jules/nagios-3.0.6$ sudo usermod -a -G nagcmd www-data
Compilation de Nagios
jules@corni:/home/jules/nagios-3.0.6$ sudo ./configure --with-command-group=nagcmd ... *** Configuration summary for nagios 3.0.6 12-01-2008 ***: General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Embedded Perl: no Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/init.d Apache conf.d directory: /etc/apache2/conf.d Mail program: /bin/mail Host OS: linux-gnu Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): Review the options above for accuracy. If they look okay, type 'make all' to compile the main program and CGIs. jules@corni:/home/jules/nagios-3.0.6$ sudo make all ... jules@corni:/home/jules/nagios-3.0.6$ sudo make install ... jules@corni:/home/jules/nagios-3.0.6$ sudo make install-init ... jules@corni:/home/jules/nagios-3.0.6$ sudo make install-config ... jules@corni:/home/jules/nagios-3.0.6$ sudo make install-commandmode ...
Compilation et installation des nagios-plugins
jules@corni:/home/jules/nagios-3.0.6$ cd ../nagios-plugins-1.4.13/ jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios ... jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo make ... jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo make install ...
Configuration de Nagios
Contacts et ContactGroups
jules@corni:/home/jules/nagios-3.0.6$ sudo vi /usr/local/nagios/etc/objects/contacts.cfg ... define contact{ contact_name nagiosadmin use generic-contact alias Nagios Admin email jules@pedrono.fr } define contact{ contact_name denis use generic-contact alias Denis Peaudeau email denispeaudeau@gmail.com } ... define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin,denis }
Installation configuration Apache
jules@corni:/home/jules/nagios-3.0.6$ sudo make install-webconf /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/conf.d/nagios.conf *** Nagios/Apache conf file installed *** jules@corni:/home/jules/nagios-3.0.6$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin jules@corni:/home/jules/nagios-3.0.6$ sudo htpasswd /usr/local/nagios/etc/htpasswd.users denis New password: Re-type new password: Adding password for user denis jules@corni:/home/jules/nagios-3.0.6$ jules@corni:/home/jules/nagios-3.0.6$ sudo /etc/init.d/apache2 reload * Reloading web server config apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.30 for ServerName [ OK ] jules@corni:/home/jules/nagios-3.0.6$
Sécurisation des accès
A FAIRE Sécuriser les accès CGI
Lancement de Nagios
Création des liens symbolique pour l'init du système
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Vérification de la configuration de Nagios
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios 3.0.6 Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org) Last Modified: 12-01-2008 License: GPL Reading configuration data... Running pre-flight check on configuration data... Checking services... Checked 8 services. Checking hosts... Checked 1 hosts. Checking host groups... Checked 1 host groups. Checking service groups... Checked 0 service groups. Checking contacts... Checked 2 contacts. Checking contact groups... Checked 1 contact groups. Checking service escalations... Checked 0 service escalations. Checking service dependencies... Checked 0 service dependencies. Checking host escalations... Checked 0 host escalations. Checking host dependencies... Checked 0 host dependencies. Checking commands... Checked 24 commands. Checking time periods... Checked 5 time periods. Checking for circular paths between hosts... Checking for circular host and service dependencies... Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check jules@corni:/home/jules/nagios-plugins-1.4.13$
Lancement de Nagios
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo /etc/init.d/nagios start Starting nagios: done. jules@corni:/home/jules/nagios-plugins-1.4.13$ ps fax ... 10688 ? Ssl 0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
Accès au service
Configuration des notifications
Installation de postfix
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo apt-get install postfix ...
- Postfix configuré comme "Système satellite".
- Nom de courrier pour le from: nagios@home.peaudeau.fr
- Relay: smtp.free.fr
ATTENTION A LA FREQUENCE ET AUX ETATS DECLENCHEURS DES NOTIFICATIONS
Installation de mailutils
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo apt-get install mailutils ... jules@corni:/home/jules/nagios-plugins-1.4.13$ ma mail mailx make-memtest86+-boot-floppy make-ssl-cert mandb mawk mailq make make_method man manpath jules@corni:/home/jules/nagios-plugins-1.4.13$ which mail /usr/bin/mail
Modification du fichier de commandes Nagios
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo vi /usr/local/nagios/etc/objects/commands.cfg
Substitution sed des référence à /bin/mail:
:%s/\/bin\/mail/\/usr\/bin\/mail/gc
Les nouvelles commandes:
# notify-host-by-email command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ }
# notify-service-by-email command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ }
Prise en compte de la configuration:
jules@corni:/home/jules/nagios-plugins-1.4.13$ sudo /etc/init.d/nagios restart Running configuration check...done. Stopping nagios: .done. Starting nagios: done. jules@corni:/home/jules/nagios-plugins-1.4.13$