Wiki » Historique » Version 67
Patrice Nadeau, 2015-02-15 12:30
| 1 | 21 | Patrice Nadeau | h1. Nagios |
|---|---|---|---|
| 2 | 1 | Patrice Nadeau | |
| 3 | 4 | Patrice Nadeau | Nagios est un système de surveillance (monitoring) d’ordinateurs, imprimantes, routeurs et de services logiciels. |
| 4 | Il existe en version payante (Nagios IX) et « open source » (Nagios Open Source). |
||
| 5 | C’est cette dernière version qui seras discutée ici. |
||
| 6 | |||
| 7 | 33 | Patrice Nadeau | >Ce guide est une introduction et ne ce veux en aucun cas une formation complète. Pour plus d’informations, consulter le site http://www.nagios.org/ |
| 8 | 24 | Patrice Nadeau | |
| 9 | 62 | Patrice Nadeau | {{lastupdated_at}} {{lastupdated_by}} |
| 10 | |||
| 11 | --- |
||
| 12 | |||
| 13 | 3 | Patrice Nadeau | {{TOC}} |
| 14 | |||
| 15 | 21 | Patrice Nadeau | h2. Installation |
| 16 | 2 | Patrice Nadeau | |
| 17 | 21 | Patrice Nadeau | h3. Requis |
| 18 | 11 | Patrice Nadeau | |
| 19 | 56 | Patrice Nadeau | * Un serveur |
| 20 | ** [[guides_opensuse:wiki|openSUSE]] |
||
| 21 | |
||
| 22 | OU |
||
| 23 | |
||
| 24 | 61 | Patrice Nadeau | ** [[guides_ubuntu:wiki|Ubuntu]] (Voir #37 pour installation avec un BeagleBone Black) |
| 25 | 4 | Patrice Nadeau | * Apache installé et configuré, |
| 26 | 26 | Patrice Nadeau | * Un serveur de courriel (Postfix ou Exim) installé et configuré, |
| 27 | 1 | Patrice Nadeau | * Une adresse IP fixe, |
| 28 | 4 | Patrice Nadeau | * Une entré DNS (enregistrement A ou CNAME). |
| 29 | 53 | Patrice Nadeau | > Un serveur physique est fortement recommandé. |
| 30 | 4 | Patrice Nadeau | |
| 31 | h3. Installation de Nagios |
||
| 32 | |||
| 33 | 31 | Patrice Nadeau | h4. [[from source|À partir des sources]] (nouvelle méthode) |
| 34 | |||
| 35 | 54 | Patrice Nadeau | Fonctionne pour openSUSE et Debian/Ubuntu |
| 36 | |||
| 37 | 31 | Patrice Nadeau | h4. [[from yast|À partir de YaST]] (ancienne méthode) |
| 38 | |||
| 39 | 55 | Patrice Nadeau | openSUSE seulement |
| 40 | |||
| 41 | 34 | Patrice Nadeau | h3. Fichiers de configuration |
| 42 | 27 | Patrice Nadeau | |
| 43 | 63 | Patrice Nadeau | L'emplacement des fichiers dépend de la méthode l’installation précédente |
| 44 | 64 | Patrice Nadeau | * openSUSE (YaST) : _/etc/nagios_ |
| 45 | 63 | Patrice Nadeau | * sources : _/usr/local/nagios_ |
| 46 | 32 | Patrice Nadeau | |
| 47 | Les principaux fichiers de configuration général sont : |
||
| 48 | 22 | Patrice Nadeau | * *nagios.cfg* : configuration de Nagios lui-même |
| 49 | 5 | Patrice Nadeau | * *ressources.cfg* : liste des macros, usagers et mots de passe |
| 50 | |||
| 51 | h2. Utilisation |
||
| 52 | |||
| 53 | Typographie dans les fichiers |
||
| 54 | * Un commentaire sur une ligne complète commence par un croisillon (#). |
||
| 55 | 21 | Patrice Nadeau | * Un commentaire à la fin d’une ligne commence par un point-virgule (;). |
| 56 | 67 | Patrice Nadeau | * Une exclusion est exprimé par un point d’exclamation (<notextile>!</notextile>) précédant l’item. |
| 57 | 10 | Patrice Nadeau | * Les items d’une liste sont séparés par une virgule (,). |
| 58 | |||
| 59 | 32 | Patrice Nadeau | h3. Fichiers d'objets |
| 60 | 10 | Patrice Nadeau | |
| 61 | 66 | Patrice Nadeau | Les fichiers de configuration sont situés dans le répertoire *objects*. |
| 62 | 32 | Patrice Nadeau | |
| 63 | 30 | Patrice Nadeau | Les principaux sont : |
| 64 | 5 | Patrice Nadeau | * *templates.cfg* |
| 65 | 65 | Patrice Nadeau | * *commands.cfg* : commandes, scripts à exécuter |
| 66 | 5 | Patrice Nadeau | * *contacts.cfg* : contacts pour les alarmes |
| 67 | * *timeperiods.cfg* : les périodes de vérifications |
||
| 68 | 7 | Patrice Nadeau | |
| 69 | L’utilisation de gabarits (« templates ») est fortement recommandée. |
||
| 70 | Un item dans un gabarit peux être redéfinis. |
||
| 71 | Ceci permet d’avoir des gabarits ayant les options par défaut et seulement les exceptions sont à définir dans les sections hôtes, groupe et services. |
||
| 72 | > Les explications suivantes prennent pour acquis l’utilisation des gabarits fournis avec Nagios. |
||
| 73 | |||
| 74 | h3. Hosts |
||
| 75 | 21 | Patrice Nadeau | |
| 76 | 6 | Patrice Nadeau | "Liste complète des paramètres pour hôte":http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#host |
| 77 | Liste des items : |
||
| 78 | * *use* : le nom du gabarit, contenu dans template.cfg |
||
| 79 | * *host_name* : nom de l’hôte, seras utilisé dans le reste de la configuration. |
||
| 80 | * *alias* : description du hôte. |
||
| 81 | * *address* : l’adresse IP ou le FQDN du hôte. |
||
| 82 | 32 | Patrice Nadeau | * *icon_image* (facultatif) : une image représentant le serveur. |
| 83 | 6 | Patrice Nadeau | * *action_url* (facultatif) : |
| 84 | |||
| 85 | Exemple : |
||
| 86 | <pre><code class="nagios"> |
||
| 87 | define host { |
||
| 88 | 5 | Patrice Nadeau | use linux−server |
| 89 | hostname linux1 |
||
| 90 | alias Serveur Linux 1 |
||
| 91 | address linux1.mydomain.com |
||
| 92 | } |
||
| 93 | </code></pre> |
||
| 94 | |||
| 95 | 21 | Patrice Nadeau | h3. Groups |
| 96 | 12 | Patrice Nadeau | |
| 97 | "Liste complète des paramètres pour les groupes d’hôtes":http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#hostgroup |
||
| 98 | |||
| 99 | Liste des items minimum : |
||
| 100 | * *hostgroup_name* : nom du groupe. |
||
| 101 | * *alias* : description du groupe. |
||
| 102 | * *members* : liste des hôtes dans ce groupe. |
||
| 103 | |||
| 104 | Exemple : |
||
| 105 | <pre><code class="nagios"> |
||
| 106 | define hostgroup { |
||
| 107 | hostgroup_name linux−servers |
||
| 108 | alias Linux servers |
||
| 109 | members linux1 |
||
| 110 | } |
||
| 111 | </code></pre> |
||
| 112 | |||
| 113 | 21 | Patrice Nadeau | h3. Services |
| 114 | 13 | Patrice Nadeau | |
| 115 | "Liste complète des paramètres pour les services":http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#service |
||
| 116 | |||
| 117 | Liste des items minimum : |
||
| 118 | * *use* : le nom du gabarit. |
||
| 119 | * *host_name* : noms des hôtes utilisant ce service. |
||
| 120 | * *service_description* : description du service. |
||
| 121 | * *check_command* : commande à effectuer. Définis dans *commands.cfg*. |
||
| 122 | |||
| 123 | 14 | Patrice Nadeau | Exemple : |
| 124 | <pre><code class="nagios"> |
||
| 125 | define service{ |
||
| 126 | use local−service |
||
| 127 | host_name localhost |
||
| 128 | service_description PING |
||
| 129 | check_command check_ping!100.0,20%!500.0,60% |
||
| 130 | } |
||
| 131 | </code></pre> |
||
| 132 | |||
| 133 | 21 | Patrice Nadeau | h2. Agents |
| 134 | 15 | Patrice Nadeau | |
| 135 | 57 | Patrice Nadeau | h3. GNU/Linux |
| 136 | 15 | Patrice Nadeau | |
| 137 | 38 | Patrice Nadeau | Problème #31 |
| 138 | |||
| 139 | 58 | Patrice Nadeau | h4. openSUSE |
| 140 | |||
| 141 | Installer *nagios-nrpe* |
||
| 142 | 36 | Patrice Nadeau | > Le « repository » n'existe plus sous openSUSE 13.2. Il faut installer *nagios-plugins* à partir de http://software.opensuse.org/ |
| 143 | 35 | Patrice Nadeau | |
| 144 | 15 | Patrice Nadeau | <pre><code class="bash"> |
| 145 | zypper install nagios−nrpe |
||
| 146 | </code></pre> |
||
| 147 | |||
| 148 | Ouvrir dans le pare feu les ports suivants : |
||
| 149 | * NRPE service (TCP 5666) |
||
| 150 | |||
| 151 | Éditer le fichier */etc/nrpe.cfg* et modifier les lignes suivantes : |
||
| 152 | * *allowed_hosts* : indiquer l’adresse IP ou le FQDN(Fully Qualified Domain Name) du serveur Nagios |
||
| 153 | |||
| 154 | Configuration du service |
||
| 155 | <pre><code class="bash"> |
||
| 156 | 37 | Patrice Nadeau | systemctl enable nrpe.service |
| 157 | 15 | Patrice Nadeau | systemctl start nrpe |
| 158 | </code></pre> |
||
| 159 | |||
| 160 | h3. Windows |
||
| 161 | 39 | Patrice Nadeau | |
| 162 | h2. Modules supplémentaires |
||
| 163 | |||
| 164 | h3. UPS |
||
| 165 | |||
| 166 | 59 | Patrice Nadeau | USP de la compagnie APC avec _apcupsd_. |
| 167 | 39 | Patrice Nadeau | |
| 168 | Pre-requis : [[guides_opensuse:ups|UPS sous openSUSE]] |
||
| 169 | 40 | Patrice Nadeau | |
| 170 | 44 | Patrice Nadeau | h4. Installation |
| 171 | 41 | Patrice Nadeau | |
| 172 | 40 | Patrice Nadeau | <pre><code class="bash"> |
| 173 | 42 | Patrice Nadeau | wget -O check_apcupsd "http://exchange.nagios.org/directory/Plugins/Hardware/UPS/APC/check_apcupsd/visit" |
| 174 | 40 | Patrice Nadeau | chmod +x check_apcupsd |
| 175 | 1 | Patrice Nadeau | mv check_apcupsd /usr/local/nagios/libexec |
| 176 | 42 | Patrice Nadeau | </code></pre> |
| 177 | |||
| 178 | Faire un test avec |
||
| 179 | <pre><code class="bash"> |
||
| 180 | /usr/local/nagios/libexec/check_apcupsd -w 50 -c 25 bcharge |
||
| 181 | </code></pre> |
||
| 182 | |||
| 183 | Si le message d'erreur suivant apparait _Error: /sbin/apcaccess must exist and be executable!_, exécuter |
||
| 184 | <pre><code class="bash"> |
||
| 185 | 43 | Patrice Nadeau | # Creer un lien symbolique vers l'executable apcaccess |
| 186 | 1 | Patrice Nadeau | ln -s /usr/sbin/apcaccess /sbin/apcaccess |
| 187 | 44 | Patrice Nadeau | </code></pre> |
| 188 | |||
| 189 | h4. Configuration |
||
| 190 | |||
| 191 | Ajouter dans le fichier *nagios/etc/objetcs/commands.cfg* : |
||
| 192 | <pre><code class="text"> |
||
| 193 | 45 | Patrice Nadeau | # Définis la commande check_apcupsd |
| 194 | 44 | Patrice Nadeau | define command{ |
| 195 | command_name check_apcupsd |
||
| 196 | command_line $USER1$/check_apcupsd -h $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ $ARG3$ |
||
| 197 | } |
||
| 198 | </code></pre> |
||
| 199 | |||
| 200 | 46 | Patrice Nadeau | Les arguments sont |
| 201 | * _$ARG1$_ : le seuil d'avertissement (warning) |
||
| 202 | 1 | Patrice Nadeau | * _$ARG2$_ : le seuil critique (critical) |
| 203 | 51 | Patrice Nadeau | * _$ARG3$_ : un des test suivants (liste complète avec _apcupsd_ sans arguments): |
| 204 | 50 | Patrice Nadeau | ** *bcharge* : charge des batteries, en pourcent |
| 205 | ** *itemp* : température interne, en Celsius |
||
| 206 | ** *loadpct* : charge en pourcent |
||
| 207 | ** *timeleft* : : temps restant selon la charge actuelle |
||
| 208 | 46 | Patrice Nadeau | |
| 209 | 50 | Patrice Nadeau | Dans le fichier *nagios/etc/objects/localhost.cfg*, inscrire les test à effectuer. |
| 210 | 46 | Patrice Nadeau | |
| 211 | >Ex. : Vérification de la charge restante, 50% étant un avertissement et 25% critique. |
||
| 212 | 44 | Patrice Nadeau | <pre><code class="text"> |
| 213 | 52 | Patrice Nadeau | # Définis le service de charge restante du UPS |
| 214 | 44 | Patrice Nadeau | define service{ |
| 215 | use local-service |
||
| 216 | 1 | Patrice Nadeau | host_name localhost |
| 217 | 45 | Patrice Nadeau | service_description UPS charge left |
| 218 | 49 | Patrice Nadeau | check_command check_apcupsd!50!25!charge |
| 219 | 44 | Patrice Nadeau | } |
| 220 | 40 | Patrice Nadeau | </code></pre> |