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