Nagios et gateway SMS Ubuntu 8.10
- Dimanche 18 janvier 2009
- Publie dansNagios
- Ecrire commentaire
Avoir une notification par SMS avec Nagios
pré requis :
gnokii – un téléphone (Nokia E50) – un cable USB (DKU2) – nagios
Installation
Connecter votre cable au pc puis votre téléphone, pour le Nokia E50, activer PCSuite depuis le téléphone.
Vérifier que votre téléphone est bien reconnu :
ls /dev/ttyACM*
Votre téléphone devrait se trouver sur /dev/ttyACM0, c’est depuis ce périphérique que le logiciel enverra les sms.
Installer l’utilitaire Gnokii :
apt-get install gnokii
Editer le fichier /etc/gnokiirc et rechercher les lignes suivantes pour les modifier :
port = /dev/ttyACM0
model = AT
connection = serial
pour tester l’envoi en direct :
echo "test envoi SMS Gnokii" | gnokii --config /etc/gnokiirc --sendsms +33123456789
Ensuite, donner les droits d’émission à Nagios pour qu’il puisse envoyer les sms et mettre l’utilisateur nagios dans le groupe dialout.
Editer le fichier /etc/group, ajouter l’utilisateur nagios au groupe dialout :
usermod -G "dialout" "nagios"
Editer le fichier /etc/nagios3/conf.d/contact_nagios2.cfg et rajouter la notification par sms au contact:
[code lang="perl"]
define contact{
contact_name nagios
alias Root
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-email, notify-by-sms
host_notification_commands notify-host-by-email, host-notify-by-sms
email nagios@localhost
pager +33123456789
}
[/code]
Editer le fichier le fichier /etc/nagios/commands.cfg :
[code lang="perl"]
define command{
command_name notify-by-sms
command_line echo "Service SMS : $NOTIFICATIONTYPE$ : $HOSTALIAS$ $SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)" | gnokii --config /etc/gnokiirc --sendsms +33123456789
}
define command{
command_name host-notify-by-sms
command_line echo "Hote SMS : $NOTIFICATIONTYPE$ : $HOSTALIAS$ $SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)" | gnokii --config /etc/gnokiirc --sendsms +33123456789
}
[/code]
Redémarrer Nagios :
/etc/init.d/nagios3 restart
Pour tester la notification, vous devoir avoir un changement d’état sur un service surveillé par Nagios (ex : SSH).
Stopper ce service et jeter un oeil dans le fichier /var/log/syslog
/etc/init.d/ssh stop
tail -f /var/log/syslog
Il faudra prendre un peu de temps mais vous aurez sous les yeux en regardant le syslog que nagios bosse pour connaitre l’état de votre service (ssh). Il va attendre un peu, histoire de prier un peu pour que le service redémarre avant de vous spamer votre GMS
)
Sources :
http://doc.ubuntu-fr.org/gsm-nokia
http://www.moroblog.info/Configurer-Smstools.html
http://www.free-4ever.info/index.php/Nagios:notifications_sms
http://blog.nicolargo.com/2008/11/notifications-nagios-par-sms.html
http://www.free-4ever.info/index.php/Communications:SMStools
http://john.mcclumpha.org/linux/Build_your_own_SMS_gateway_with_Ubuntu_Linux_and_Gammu/
http://doc.ubuntu-fr.org/gammu
http://cihar.com/gammu/phonedb/nokia/352/
o:) http://www.zoneminder.com/forums/viewtopic.php?t=10976
http://dt.in.th/2008-01-02.linux-sending-sms.html
http://wiki.gnokii.org/index.php/Cables#DKU-2.2C_CA-53_and_CA-70
http://www.gnokii.org/docs.shtml#dku
Pas encore de commentaires.