Projet

Général

Profil

Wiki » Historique » Version 126

Patrice Nadeau, 2018-08-18 08:40

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