Pré-requis
Une installation de Nagios fonctionnelle ! Et :
apt-get install libcgi-pm-perl librrds-perl libgd-gd2-perl
Récupérer le .deb sur le site
http://sourceforge.net/projects/nagiosgraph/files/nagiosgraph/
Installer Nagiosgraph
dpkg -i nagiosgraph.deb
Vérifier la configuration
L’installation a du ajouter les lignes suivantes au fichier /etc/nagios3/nagios.cfg :
# begin nagiosgraph configuration # process nagios performance data using nagiosgraph process_performance_data=1 service_perfdata_file=/tmp/perfdata.log service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$ service_perfdata_file_mode=a service_perfdata_file_processing_interval=30 service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph # end nagiosgraph configuration
Dans commands.cfg, Nagiosgraph a ajouté cette commande :
# begin nagiosgraph configuration
# command to process nagios performance data for nagiosgraph
define command {
command_name process-service-perfdata-for-nagiosgraph
command_line /usr/lib/nagiosgraph/insert.pl
}
# end nagiosgraph configuration
Vérifier la configuration nagiosgraph.conf
/etc/nagiosgraph/nagiosgraph.conf, normalement, il n’y a rien à modifier, on remarque que le fichier d’ »échange » des données de performances entre Nagios et Nagiosgraph sera /tmp/perfdata.log.
perflog = /tmp/perfdata.log
Modifier la définition des hosts
Ajouter « action_url », ceci va ajouter un lien vers les graphiques sur chaque host dans l’interface web Nagios.
define host{
use generic-host
host_name HOST
alias HOST
address 192.168.1.1
action_url /nagiosgraph/cgi-bin/showhost.cgi?host=$HOSTNAME$
}
Recharger le service nagios.
Pour vérifier le fonctionnement
tail -f /tmp/perfdata.log
Problème rencontré
Les graphs ne sont pas réalisé, les logs « /var/log/nagiosgraph/nagiosgraph.log » montrent ce genre d’erreur :
error RRDs::update ERR[...]conversion of '0,000000' to float not complete: tail ',000000'
Ceci signifie que les RRD ne sont pas capable de traiter les résultats des checks qui comportent des virgules.
1ere solution à ne pas utiliser
A ne pas utiliser, car elle génère des problèmes d’interprétation des codes de sorties des plugins (0,1 ou 2 pour OK, Warning et Critical). Avec cette solution, le code de sortie est toujours OK.
Cette solution, remplacer les virgules par un point au moment de l’exécution d’un check. Par exemple pour la commande check_nt, modifier le fichier /etc/nagios-plugins/config/nt.cfg et ajouter « | sed ‘s/,/./g’ » (sans guillemet à la fin de la commande_line), ce qui donne :
# !! NE PAS UTILISER CETTE SOLUTION !!
#
# 'check_nt' command definition
define command {
command_name check_nt
command_line /usr/lib/nagios/plugins/check_nt -H $HOSTADDRESS$ -p 12489 -s user -v $ARG1$ $ARG2$ | sed 's/,/./g'
}
Solution retenue : modifier la locale à l’exécution du plugin check_nt
Pour ce faire, modifier la commande du plugin check_nt et ajouter LC_ALL=C LANG=C avant la ligne de commande d’exécution du plugin. Cette locale (C) permettra une sortie du plugin sans virgule.
# 'check_nt' command definition
define command {
command_name check_nt
command_line LC_ALL=C LANG=C /usr/lib/nagios/plugins/check_nt -H $HOSTADDRESS$ -p 12489 -s user -v $ARG1$ $ARG2$
}