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