Tuesday, August 31, 2010

Zabbix SMS queuing.

I had a problem with the sms program we use just dropping sms's if you tried to send too many at one time.

I'm using the following script in zabbix to interface with gammu the sms tool.
#!/usr/bin/env bash

LOCKFILE=/tmp/sms.lock
LOCKED="false"

echo "waiting for lock" |logger -t "sms" -i -p local3.info
while [ "${LOCKED}" = "false" ]
do
if [ ! -f ${LOCKFILE} ]; then
echo "$$" > ${LOCKFILE}
fi
if [ "$$" = "`cat ${LOCKFILE}`" ]; then
LOCKED="true"
fi
done
echo "got lock." |logger -t "sms" -i -p local3.info

trap "{ rm -f $LOCKFILE ; exit 255; }" EXIT
echo "sending sms to: $1" |logger -t "sms" -i -p local3.info
echo "$2 $3 $4 $5 $6 $7 $8 $9" | /usr/bin/gammu sendsms TEXT $1 > /dev/null 2>&1

exit 0
Maybe someone else will find this useful.

No comments:

Post a Comment