Wiki » Historique » Version 113
Patrice Nadeau, 2017-07-27 18:32
| 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 | 91 | Patrice Nadeau | * [[guides_opensuse:Apache|Apache]] fonctionnel avec |
| 26 | 89 | Patrice Nadeau | ** _mod_version_, |
| 27 | ** _mod_php5_, |
||
| 28 | 93 | Patrice Nadeau | * Un serveur de courriel ([[guides_opensuse:Postfix|Postfix]] ou Exim) fonctionnel, |
| 29 | 1 | Patrice Nadeau | * Une adresse IP fixe, |
| 30 | 4 | Patrice Nadeau | * Une entré DNS (enregistrement A ou CNAME). |
| 31 | 92 | Patrice Nadeau | > Un ordinateur physique est fortement recommandé. |
| 32 | 4 | Patrice Nadeau | |
| 33 | h3. Installation de Nagios |
||
| 34 | |||
| 35 | 31 | Patrice Nadeau | h4. [[from source|À partir des sources]] (nouvelle méthode) |
| 36 | |||
| 37 | 54 | Patrice Nadeau | Fonctionne pour openSUSE et Debian/Ubuntu |
| 38 | |||
| 39 | 68 | Patrice Nadeau | h2. Modification de l'adresse d’envoi |
| 40 | |||
| 41 | 76 | Patrice Nadeau | Par défaut, les alertes vont provenir de _nagios@nagios.domain.tld_. |
| 42 | Certains système de courriel peuvent bloquer ces messages si le sous-domaine _nagios.domain.tld_ n'existe pas. |
||
| 43 | 69 | Patrice Nadeau | |
| 44 | Pour changer l'adresse « from », modifier le fichier *etc/objects/command.cfg* pour les commandes : |
||
| 45 | * notify-host-by-email |
||
| 46 | * notify-service-by-email |
||
| 47 | |||
| 48 | Ajouter à la fin de la ligne de commande (_command_line_) : |
||
| 49 | <pre><code class="bash"> |
||
| 50 | 76 | Patrice Nadeau | -- -f nagios@domain.tld |
| 51 | </code></pre> |
||
| 52 | 68 | Patrice Nadeau | |
| 53 | 70 | Patrice Nadeau | h2. Utilisation |
| 54 | |||
| 55 | Typographie dans les fichiers |
||
| 56 | * Un commentaire sur une ligne complète commence par un croisillon (#). |
||
| 57 | * Un commentaire à la fin d’une ligne commence par un point-virgule (;). |
||
| 58 | * Une exclusion est exprimé par un point d’exclamation (<notextile>!</notextile>) précédant l’item. |
||
| 59 | * Les items d’une liste sont séparés par une virgule (,). |
||
| 60 | |||
| 61 | 34 | Patrice Nadeau | h3. Fichiers de configuration |
| 62 | 5 | Patrice Nadeau | |
| 63 | L'emplacement des fichiers dépend de la méthode l’installation précédente |
||
| 64 | * openSUSE (YaST) : _/etc/nagios_ |
||
| 65 | * sources : _/usr/local/nagios_ |
||
| 66 | |||
| 67 | 21 | Patrice Nadeau | Les principaux fichiers de configuration général sont : |
| 68 | 67 | Patrice Nadeau | * *nagios.cfg* : configuration de Nagios lui-même |
| 69 | 10 | Patrice Nadeau | * *ressources.cfg* : liste des macros, usagers et mots de passe |
| 70 | |||
| 71 | 32 | Patrice Nadeau | h3. Fichiers d'objets |
| 72 | 10 | Patrice Nadeau | |
| 73 | 66 | Patrice Nadeau | Les fichiers de configuration sont situés dans le répertoire *objects*. |
| 74 | 32 | Patrice Nadeau | |
| 75 | 30 | Patrice Nadeau | Les principaux sont : |
| 76 | 5 | Patrice Nadeau | * *templates.cfg* |
| 77 | 65 | Patrice Nadeau | * *commands.cfg* : commandes, scripts à exécuter |
| 78 | 5 | Patrice Nadeau | * *contacts.cfg* : contacts pour les alarmes |
| 79 | * *timeperiods.cfg* : les périodes de vérifications |
||
| 80 | 7 | Patrice Nadeau | |
| 81 | L’utilisation de gabarits (« templates ») est fortement recommandée. |
||
| 82 | Un item dans un gabarit peux être redéfinis. |
||
| 83 | 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. |
||
| 84 | > Les explications suivantes prennent pour acquis l’utilisation des gabarits fournis avec Nagios. |
||
| 85 | |||
| 86 | h3. Hosts |
||
| 87 | 21 | Patrice Nadeau | |
| 88 | 6 | Patrice Nadeau | "Liste complète des paramètres pour hôte":http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#host |
| 89 | Liste des items : |
||
| 90 | * *use* : le nom du gabarit, contenu dans template.cfg |
||
| 91 | * *host_name* : nom de l’hôte, seras utilisé dans le reste de la configuration. |
||
| 92 | * *alias* : description du hôte. |
||
| 93 | * *address* : l’adresse IP ou le FQDN du hôte. |
||
| 94 | 32 | Patrice Nadeau | * *icon_image* (facultatif) : une image représentant le serveur. |
| 95 | 6 | Patrice Nadeau | * *action_url* (facultatif) : |
| 96 | |||
| 97 | Exemple : |
||
| 98 | <pre><code class="nagios"> |
||
| 99 | define host { |
||
| 100 | 5 | Patrice Nadeau | use linux−server |
| 101 | hostname linux1 |
||
| 102 | alias Serveur Linux 1 |
||
| 103 | address linux1.mydomain.com |
||
| 104 | } |
||
| 105 | </code></pre> |
||
| 106 | |||
| 107 | 21 | Patrice Nadeau | h3. Groups |
| 108 | 12 | Patrice Nadeau | |
| 109 | "Liste complète des paramètres pour les groupes d’hôtes":http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#hostgroup |
||
| 110 | |||
| 111 | Liste des items minimum : |
||
| 112 | * *hostgroup_name* : nom du groupe. |
||
| 113 | * *alias* : description du groupe. |
||
| 114 | * *members* : liste des hôtes dans ce groupe. |
||
| 115 | |||
| 116 | Exemple : |
||
| 117 | <pre><code class="nagios"> |
||
| 118 | define hostgroup { |
||
| 119 | hostgroup_name linux−servers |
||
| 120 | alias Linux servers |
||
| 121 | members linux1 |
||
| 122 | } |
||
| 123 | </code></pre> |
||
| 124 | |||
| 125 | 21 | Patrice Nadeau | h3. Services |
| 126 | 13 | Patrice Nadeau | |
| 127 | "Liste complète des paramètres pour les services":http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#service |
||
| 128 | |||
| 129 | Liste des items minimum : |
||
| 130 | * *use* : le nom du gabarit. |
||
| 131 | * *host_name* : noms des hôtes utilisant ce service. |
||
| 132 | * *service_description* : description du service. |
||
| 133 | * *check_command* : commande à effectuer. Définis dans *commands.cfg*. |
||
| 134 | |||
| 135 | 14 | Patrice Nadeau | Exemple : |
| 136 | <pre><code class="nagios"> |
||
| 137 | define service{ |
||
| 138 | use local−service |
||
| 139 | host_name localhost |
||
| 140 | service_description PING |
||
| 141 | check_command check_ping!100.0,20%!500.0,60% |
||
| 142 | } |
||
| 143 | </code></pre> |
||
| 144 | |||
| 145 | 102 | Patrice Nadeau | h2. NRPE |
| 146 | |||
| 147 | h3. Modules supplémentaires |
||
| 148 | |||
| 149 | [[NRPE]] |
||
| 150 | |||
| 151 | 21 | Patrice Nadeau | h2. Agents |
| 152 | 15 | Patrice Nadeau | |
| 153 | 57 | Patrice Nadeau | h3. GNU/Linux |
| 154 | 15 | Patrice Nadeau | |
| 155 | 1 | Patrice Nadeau | Installer *nagios-nrpe* |
| 156 | |||
| 157 | 98 | Patrice Nadeau | h4. Version déjà compilée |
| 158 | |||
| 159 | opensSUSE |
||
| 160 | 1 | Patrice Nadeau | <pre><code class="bash"> |
| 161 | 94 | Patrice Nadeau | wget http://download.opensuse.org/repositories/openSUSE:/Leap:/42.2/standard/x86_64/nrpe-2.15-9.1.x86_64.rpm |
| 162 | 1 | Patrice Nadeau | rpm -Uhv nrpe-2.15-9.1.x86_64.rpm |
| 163 | </code></pre> |
||
| 164 | 94 | Patrice Nadeau | |
| 165 | 98 | Patrice Nadeau | h4. À partir des sources |
| 166 | |||
| 167 | 101 | Patrice Nadeau | Voir [[NRPE]] |
| 168 | 79 | Patrice Nadeau | |
| 169 | 15 | Patrice Nadeau | h3. Windows |
| 170 | 39 | Patrice Nadeau | |
| 171 | 77 | Patrice Nadeau | À venir ... |
| 172 | |||
| 173 | 39 | Patrice Nadeau | h2. Modules supplémentaires |
| 174 | |||
| 175 | h3. UPS |
||
| 176 | |||
| 177 | 59 | Patrice Nadeau | USP de la compagnie APC avec _apcupsd_. |
| 178 | 39 | Patrice Nadeau | |
| 179 | Pre-requis : [[guides_opensuse:ups|UPS sous openSUSE]] |
||
| 180 | 40 | Patrice Nadeau | |
| 181 | 44 | Patrice Nadeau | h4. Installation |
| 182 | 41 | Patrice Nadeau | |
| 183 | 40 | Patrice Nadeau | <pre><code class="bash"> |
| 184 | 42 | Patrice Nadeau | wget -O check_apcupsd "http://exchange.nagios.org/directory/Plugins/Hardware/UPS/APC/check_apcupsd/visit" |
| 185 | 40 | Patrice Nadeau | chmod +x check_apcupsd |
| 186 | 1 | Patrice Nadeau | mv check_apcupsd /usr/local/nagios/libexec |
| 187 | 42 | Patrice Nadeau | </code></pre> |
| 188 | |||
| 189 | Faire un test avec |
||
| 190 | <pre><code class="bash"> |
||
| 191 | /usr/local/nagios/libexec/check_apcupsd -w 50 -c 25 bcharge |
||
| 192 | </code></pre> |
||
| 193 | |||
| 194 | Si le message d'erreur suivant apparait _Error: /sbin/apcaccess must exist and be executable!_, exécuter |
||
| 195 | <pre><code class="bash"> |
||
| 196 | 43 | Patrice Nadeau | # Creer un lien symbolique vers l'executable apcaccess |
| 197 | 1 | Patrice Nadeau | ln -s /usr/sbin/apcaccess /sbin/apcaccess |
| 198 | 44 | Patrice Nadeau | </code></pre> |
| 199 | |||
| 200 | h4. Configuration |
||
| 201 | |||
| 202 | Ajouter dans le fichier *nagios/etc/objetcs/commands.cfg* : |
||
| 203 | <pre><code class="text"> |
||
| 204 | 45 | Patrice Nadeau | # Définis la commande check_apcupsd |
| 205 | 44 | Patrice Nadeau | define command{ |
| 206 | command_name check_apcupsd |
||
| 207 | command_line $USER1$/check_apcupsd -h $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ $ARG3$ |
||
| 208 | } |
||
| 209 | </code></pre> |
||
| 210 | |||
| 211 | 46 | Patrice Nadeau | Les arguments sont |
| 212 | * _$ARG1$_ : le seuil d'avertissement (warning) |
||
| 213 | 1 | Patrice Nadeau | * _$ARG2$_ : le seuil critique (critical) |
| 214 | 51 | Patrice Nadeau | * _$ARG3$_ : un des test suivants (liste complète avec _apcupsd_ sans arguments): |
| 215 | 50 | Patrice Nadeau | ** *bcharge* : charge des batteries, en pourcent |
| 216 | ** *itemp* : température interne, en Celsius |
||
| 217 | ** *loadpct* : charge en pourcent |
||
| 218 | ** *timeleft* : : temps restant selon la charge actuelle |
||
| 219 | 46 | Patrice Nadeau | |
| 220 | 50 | Patrice Nadeau | Dans le fichier *nagios/etc/objects/localhost.cfg*, inscrire les test à effectuer. |
| 221 | 46 | Patrice Nadeau | |
| 222 | >Ex. : Vérification de la charge restante, 50% étant un avertissement et 25% critique. |
||
| 223 | 44 | Patrice Nadeau | <pre><code class="text"> |
| 224 | 52 | Patrice Nadeau | # Définis le service de charge restante du UPS |
| 225 | 44 | Patrice Nadeau | define service{ |
| 226 | use local-service |
||
| 227 | 1 | Patrice Nadeau | host_name localhost |
| 228 | 45 | Patrice Nadeau | service_description UPS charge left |
| 229 | 49 | Patrice Nadeau | check_command check_apcupsd!50!25!charge |
| 230 | 44 | Patrice Nadeau | } |
| 231 | 40 | Patrice Nadeau | </code></pre> |
| 232 | 71 | Patrice Nadeau | |
| 233 | h2. Nagstatmon |
||
| 234 | |||
| 235 | Logiciel de notification Nagios pour poste de travail. |
||
| 236 | |||
| 237 | Télécharger à partir de https://nagstamon.ifw-dresden.de/download |
||
| 238 | |||
| 239 | h3. GNU/Linux |
||
| 240 | |||
| 241 | h4. openSUSE |
||
| 242 | |||
| 243 | 72 | Patrice Nadeau | Utilisé la version disponible à http://software.opensuse.org/package/nagstamon?search_term=nagstamon |
| 244 | |||
| 245 | 71 | Patrice Nadeau | <pre><code class="bash"> |
| 246 | 86 | Patrice Nadeau | sudo zypper install nagstamon-1.0.1-1.1.noarch.rpm |
| 247 | 71 | Patrice Nadeau | </code></pre> |
| 248 | 74 | Patrice Nadeau | |
| 249 | 103 | Patrice Nadeau | |
| 250 | 75 | Patrice Nadeau | h2. [[Plugins maison]] |