Projet

Général

Profil

Wiki » Historique » Version 124

Patrice Nadeau, 2018-08-18 08:13

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