Projet

Général

Profil

Wiki » Historique » Version 122

Patrice Nadeau, 2018-04-15 14:25

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