Projet

Général

Profil

Wiki » Historique » Version 114

Patrice Nadeau, 2018-04-15 13:47

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