Ipfire : Configurer Nagios

Voici la procédure que j’ai suivis pour configurer nagios dans ipfire.nagios dans ipfire

Procédure :

  • Créer l’utilisateur nagios et lui attribuer la propriété sur nagios.

[code lang= »bash »]
useradd nagios -s /bin/false -d /var/nagios
chown nagios: /etc/nagios/*.cfg
chown nagios: /etc/nagios/objects/*.cfg
chown nagios: /var/nagios/ -R
sed -i.bak ‘s/^nagios_user=.*/nagios_user=nagios/’ /etc/nagios/nagios.cfg
sed -i.bak ‘s/^nagios_group=.*/nagios_group=nagios/’ /etc/nagios/nagios.cfg
sed -i.bak ‘s/^NagiosUser=.*/NagiosUser=nagios/’ /etc/init.d/nagios
sed -i.bak ‘s/^NagiosGroup=.*/NagiosGroup=nagios/’ /etc/init.d/nagios
[/code]

  • Configurer son compte utilisateur, modifier /etc/nagios/objects/contacts.cfg

[code lang= »bash »]define contact{
contact_name webmaster; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias webmaster ; Full name of user

email webmaster@jbsky.fr ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members webmaster
}[/code]

  • Modifier le mot de passe:

[code lang= »bash »]htpasswd -c /etc/nagios/htpasswd.users webmaster
[/code]

  • Ajouter la commande dans le fichier /etc/nagios/objects/commands.cfg

[code lang= »bash »]# ‘check_https_ipfire’ command definition
define command{
command_name check_https_ipfire
command_line $USER1$/check_http -S -I $HOSTADDRESS$ $ARG1$ -p 444 -a admin:motdepass
}[/code]

  • Rectifier le service https sur le port 444, chercher check_http dans le fichier cat /etc/nagios/objects/localhost.cfg et le tout remplacer par

[code lang= »bash »]define service{
use local-service ; Name of service template to use
host_name localhost
service_description HTTPS_444
check_command check_https_ipfire
notifications_enabled 0
}[/code]

  • Changer le format de date dans /etc/nagios/nagios.cfg

[code lang= »bash »]
sed -i.bak ‘s/^date_format=.*/date_format=euro/’ /etc/init.d/nagios
[/code]

  • Modifié les commandes de notification dans  /etc/nagios/objects/commands.cfg pour que nagios envoie des mails, ajouter le package sendEmail depuis pakfire.

[code lang= »bash »]
# ‘notify-host-by-email’ command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b ***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n** " | /usr/local/bin/sendEmail -f agent.nagios@jbsky.fr -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ ** " -s 10.0.0.4 -xp motdepass -v
}

# ‘notify-host-by-email’ command definition
define command{
command_name host-notify-by-email
command_line /usr/bin/printf "%b ***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n** " | /usr/local/bin/sendEmail -f agent.nagios@jbsky.fr -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ ** " -s 10.0.0.4 -xp motdepass -v
}

# ‘notify-service-by-email’ command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b ***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -f agent.nagios@jbsky.fr -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -s 10.0.0.4 -xp motdepass -v

}

# ‘notify-service-by-email’ command definition
define command{
command_name service-notify-by-email
command_line /usr/bin/printf "%b ***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -f agent.nagios@jbsky.fr -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -s 10.0.0.4 -xp motdepass -v
}
[/code]

  • Recharger Nagios:

[code lang= »bash »]/etc/init.d/nagios reload[/code]

  1. Application Iphone intéressante:

TM-Lite
Fournir l’URL complète: http://IP:1008/nagios/cgi-bin