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