Smstools

Un article de OpenWikiBSD.

Objectif : Envoyer (ou recevoir) des SMS depuis une machine, et ce de manière automatique, ou lorsqu'un évènement survient (Souci Nagios, réception mail, crontab,....)

On travaille sous Debian Lenny 5.0

  • Installation
apt-get install smstools
  • vi /etc/smsd.conf (On modifie la ligne device = ///// dnas la partie GSM1 )
    • Un tail -f /var/log/daemon.log donne le nom du device , chez moi :/dev/ttyACM0
  • Une boulette dans les droits :
 chown -R smsd.smsd /var/log/sms* 
  • On relance
 /etc/init.d/smstools restart
  • Un script piqué d'ici
#!/bin/sh
# This script send a text sms at the command line by creating
# a sms file in the outgoing queue.
# I use it for testing.
# $1 is the destination phone number
# $2 is the message text
# if you leave $2 or both empty, the script will ask you
DEST=$1
DEST=33N°Tel au format international : Le 336XXXXX au lieu du 06XXXXX

TEXT=$2
if [ -z "$DEST" ]; then
printf "Destination: "
read DEST
fi
if [ -z "$TEXT" ]; then
printf "Text: "
read TEXT
fi
FILE=`mktemp /var/spool/sms/outgoing/send_XXXXXX`
chown smsd $FILE
echo "To: $DEST" >> $FILE
echo "" >> $FILE
echo "$TEXT" >> $FILE

  • Puis un simple echo "Systèmes opérationnels Captain Kirk" | sendsms.sh, et c'est parti pour du monitoring temps-réel.
  • Tout se passe dans /var/spool/sms, avec des outgoing, des incoming, des sent...
  • Todo :
    • Récupérer les Tel de manière automatique depuis le LDAP du SAmbaedu3
    • faire bosser Nagios avec