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