Wiki » Historique » Version 104
Patrice Nadeau, 2017-04-29 11:38
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 | 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 | 102 | Patrice Nadeau | h2. NRPE |
150 | |||
151 | h3. Modules supplémentaires |
||
152 | |||
153 | [[NRPE]] |
||
154 | |||
155 | 21 | Patrice Nadeau | h2. Agents |
156 | 15 | Patrice Nadeau | |
157 | 57 | Patrice Nadeau | h3. GNU/Linux |
158 | 15 | Patrice Nadeau | |
159 | 1 | Patrice Nadeau | Installer *nagios-nrpe* |
160 | |||
161 | 98 | Patrice Nadeau | h4. Version déjà compilée |
162 | |||
163 | opensSUSE |
||
164 | 1 | Patrice Nadeau | <pre><code class="bash"> |
165 | 94 | Patrice Nadeau | wget http://download.opensuse.org/repositories/openSUSE:/Leap:/42.2/standard/x86_64/nrpe-2.15-9.1.x86_64.rpm |
166 | 1 | Patrice Nadeau | rpm -Uhv nrpe-2.15-9.1.x86_64.rpm |
167 | </code></pre> |
||
168 | 94 | Patrice Nadeau | |
169 | 98 | Patrice Nadeau | h4. À partir des sources |
170 | |||
171 | 101 | Patrice Nadeau | Voir [[NRPE]] |
172 | 79 | Patrice Nadeau | |
173 | 99 | Patrice Nadeau | h4. Configuration |
174 | |||
175 | 84 | Patrice Nadeau | Ouvrir dans le pare feu le port TCP 5666 : |
176 | <pre><code class="bash"> |
||
177 | yast firewall services add service=service:nrpe zone=EXT |
||
178 | </code></pre> |
||
179 | 15 | Patrice Nadeau | |
180 | Éditer le fichier */etc/nrpe.cfg* et modifier les lignes suivantes : |
||
181 | * *allowed_hosts* : indiquer l’adresse IP ou le FQDN(Fully Qualified Domain Name) du serveur Nagios |
||
182 | |||
183 | Configuration du service |
||
184 | <pre><code class="bash"> |
||
185 | 37 | Patrice Nadeau | systemctl enable nrpe.service |
186 | 85 | Patrice Nadeau | systemctl start nrpe.service |
187 | 15 | Patrice Nadeau | </code></pre> |
188 | |||
189 | h3. Windows |
||
190 | 39 | Patrice Nadeau | |
191 | 77 | Patrice Nadeau | À venir ... |
192 | |||
193 | 39 | Patrice Nadeau | h2. Modules supplémentaires |
194 | |||
195 | h3. UPS |
||
196 | |||
197 | 59 | Patrice Nadeau | USP de la compagnie APC avec _apcupsd_. |
198 | 39 | Patrice Nadeau | |
199 | Pre-requis : [[guides_opensuse:ups|UPS sous openSUSE]] |
||
200 | 40 | Patrice Nadeau | |
201 | 44 | Patrice Nadeau | h4. Installation |
202 | 41 | Patrice Nadeau | |
203 | 40 | Patrice Nadeau | <pre><code class="bash"> |
204 | 42 | Patrice Nadeau | wget -O check_apcupsd "http://exchange.nagios.org/directory/Plugins/Hardware/UPS/APC/check_apcupsd/visit" |
205 | 40 | Patrice Nadeau | chmod +x check_apcupsd |
206 | 1 | Patrice Nadeau | mv check_apcupsd /usr/local/nagios/libexec |
207 | 42 | Patrice Nadeau | </code></pre> |
208 | |||
209 | Faire un test avec |
||
210 | <pre><code class="bash"> |
||
211 | /usr/local/nagios/libexec/check_apcupsd -w 50 -c 25 bcharge |
||
212 | </code></pre> |
||
213 | |||
214 | Si le message d'erreur suivant apparait _Error: /sbin/apcaccess must exist and be executable!_, exécuter |
||
215 | <pre><code class="bash"> |
||
216 | 43 | Patrice Nadeau | # Creer un lien symbolique vers l'executable apcaccess |
217 | 1 | Patrice Nadeau | ln -s /usr/sbin/apcaccess /sbin/apcaccess |
218 | 44 | Patrice Nadeau | </code></pre> |
219 | |||
220 | h4. Configuration |
||
221 | |||
222 | Ajouter dans le fichier *nagios/etc/objetcs/commands.cfg* : |
||
223 | <pre><code class="text"> |
||
224 | 45 | Patrice Nadeau | # Définis la commande check_apcupsd |
225 | 44 | Patrice Nadeau | define command{ |
226 | command_name check_apcupsd |
||
227 | command_line $USER1$/check_apcupsd -h $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ $ARG3$ |
||
228 | } |
||
229 | </code></pre> |
||
230 | |||
231 | 46 | Patrice Nadeau | Les arguments sont |
232 | * _$ARG1$_ : le seuil d'avertissement (warning) |
||
233 | 1 | Patrice Nadeau | * _$ARG2$_ : le seuil critique (critical) |
234 | 51 | Patrice Nadeau | * _$ARG3$_ : un des test suivants (liste complète avec _apcupsd_ sans arguments): |
235 | 50 | Patrice Nadeau | ** *bcharge* : charge des batteries, en pourcent |
236 | ** *itemp* : température interne, en Celsius |
||
237 | ** *loadpct* : charge en pourcent |
||
238 | ** *timeleft* : : temps restant selon la charge actuelle |
||
239 | 46 | Patrice Nadeau | |
240 | 50 | Patrice Nadeau | Dans le fichier *nagios/etc/objects/localhost.cfg*, inscrire les test à effectuer. |
241 | 46 | Patrice Nadeau | |
242 | >Ex. : Vérification de la charge restante, 50% étant un avertissement et 25% critique. |
||
243 | 44 | Patrice Nadeau | <pre><code class="text"> |
244 | 52 | Patrice Nadeau | # Définis le service de charge restante du UPS |
245 | 44 | Patrice Nadeau | define service{ |
246 | use local-service |
||
247 | 1 | Patrice Nadeau | host_name localhost |
248 | 45 | Patrice Nadeau | service_description UPS charge left |
249 | 49 | Patrice Nadeau | check_command check_apcupsd!50!25!charge |
250 | 44 | Patrice Nadeau | } |
251 | 40 | Patrice Nadeau | </code></pre> |
252 | 71 | Patrice Nadeau | |
253 | h2. Nagstatmon |
||
254 | |||
255 | Logiciel de notification Nagios pour poste de travail. |
||
256 | |||
257 | Télécharger à partir de https://nagstamon.ifw-dresden.de/download |
||
258 | |||
259 | h3. GNU/Linux |
||
260 | |||
261 | h4. openSUSE |
||
262 | |||
263 | 72 | Patrice Nadeau | Utilisé la version disponible à http://software.opensuse.org/package/nagstamon?search_term=nagstamon |
264 | |||
265 | 71 | Patrice Nadeau | <pre><code class="bash"> |
266 | 86 | Patrice Nadeau | sudo zypper install nagstamon-1.0.1-1.1.noarch.rpm |
267 | 71 | Patrice Nadeau | </code></pre> |
268 | 74 | Patrice Nadeau | |
269 | 103 | Patrice Nadeau | Source |
270 | 104 | Patrice Nadeau | openSUSE : |
271 | 1 | Patrice Nadeau | <pre><code class="bash"> |
272 | 104 | Patrice Nadeau | sudo zypper install python-configparser |
273 | 103 | Patrice Nadeau | wget https://nagstamon.ifw-dresden.de/files/stable/Nagstamon-2.0.1.tar.gz |
274 | python setup.py install |
||
275 | </code></pre> |
||
276 | |||
277 | 75 | Patrice Nadeau | h2. [[Plugins maison]] |