Projet

Général

Profil

Wiki » Historique » Version 116

Patrice Nadeau, 2018-04-15 13:53

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