>>> I. Test et verification
Nagios adopte une configuration modulaire, il n’est pas rare d’oublier le definition d’un contact, oublier une parenthese,….
Pour tester votre configuration actuelle de Nagios executer /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Voici le resultat:
$/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios 2.9
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 04-10-2007
License: GPL
Reading configuration data…
Running pre-flight check on configuration data…
Checking services…
Warning: Service ‘Load’ on host ‘Serveur_01′ has no default contact group(s) defined!
Checked 155 services.
Checking hosts…
Warning: Host ‘Serveur_02′ has no services associated with it!
Checked 94 hosts.
Checking host groups…
Checked 14 host groups.
Checking service groups…
Checked 1 service groups.
Checking contacts…
Checked 3 contacts.
Checking contact groups…
Checked 2 contact groups.
Checking service escalations…
Checked 0 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 0 host escalations.
Checking host dependencies…
Checked 0 host dependencies.
Checking commands…
Checked 30 commands.
Checking time periods…
Checked 5 time periods.
Checking extended host info definitions…
Checked 0 extended host info definitions.
Checking extended service info definitions…
Checked 0 extended service info definitions.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…
Total Warnings: 2
Total Errors: 0
Things look okay – No serious problems were detected during the pre-flight check
J’ai volontairement laissé de “petites” erreurs dans la configuration, ces dernieres sont sans conséquences pour le bon fonctionnement de Nagios, il s’agit de Warning. Nagios pourra etre lancé.
Si nous avions eu une erreur, par exemple
$/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios 2.9
Copyright (c) 1999-2007 Ethan Galstad (http://www.nagios.org)
Last Modified: 04-10-2007
License: GPL
Reading configuration data…
Error: Could not find any host matching ‘Serveur_99′
Error: Could not expand hostgroups and/or hosts specified in service (config file ‘/usr/local/nagios/etc/services.cfg’, starting on line 12)
***> One or more problems was encountered while processing the config files…
Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
‘Whats New’ section to find out what has changed.
J’ai volontairement defini un service avec un serveur qui n’etait pas defini, ce qui explique l’erreur ci dessus.
Il faut donc corriger toutes les erreurs, nous pourrons ensuite demarrer nagios
>>> II. Lancement
# Lacement classique (foreground process)
$ /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
> pour l’arret un CTRL+C suffit
To stop Nagios at any time, just press CTRL-C. If you’ve enabled the debugging options you’ll probably want to redirect the output to a file for easier review later.
# Lancement silencieux (Background Process)
$ /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg &
# Lancement en tant que Daemon
$ /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
Ces differentes methodes sont utiles sur des plateformes de test ou sur un pc pour tester le produit, en fonctionnement de production, il faudra adapter le choix suivant.
# Start Nagios
$ /etc/rc.d/init.d/nagios start
# Stop Nagios (tue le process lancé par nagios start)
$ /etc/rc.d/init.d/nagios stop
# Restart Nagios (=nagios stop puis nagios start)
$ /etc/rc.d/init.d/nagios restart
# Reload Configuration Data (envois un SIGHUP au process Nagios, forcant une prise en compte immédiate des nouveaux fichiers de configuration, l’avantage est de ne pas couper le process, par exemple an cas d’ajout d’un serveur ou d’un service)
$ /etc/rc.d/init.d/nagios reload