SMS support for Zabbix

Friday, September 02 2005 @ 05:01 PM CEST

Contributed by: bart

I use the popular monitoring tool Zabbix and wanted it to be able to send messages to cellphones and pagers. The obvious solution is to use one of the Internet based gateways, but that has the obvious problem of not workign when Zabbix wants to inform me about connection problems.

The solution for this is using a modem and an sms or pager client. sms_client is a tool that combines both.

Configuring sms_client to work properly with Zabbix is not as straightforward as you might think. The problem is that the alert scripts in Zabbix are started from some PHP script. When the alert script generates output (and doesn't redirect it to some file or /dev/null) it will hang there forever once it is finished, it will never terminate. The result is that the first message works, and after that it won't work anymore.

The solution is to use a script like the one provided here:

#!/usr/local/bin/bash

NUMBER=$1
shift

MSG="ZABBIX: "$(echo $* | head -c 150 | sed -e $(printf "s/\r*//g") )

echo $ | /usr/local/bin/sms_client -l 4 kpn:$ >>/var/log/sms_client.log

This of course assumes one receipiant per message only, but since many sms centers do not really support more then one destination anyway this is usually not an issue.

This setup has the nice side effect that you also get a session log (should normally goto /dev/null, but for now goes into /var/log/sms_client.log for debugging)

Nov. 16 2005, updated the script to strip cr/lf and ensure messages are within the limit for length.

3 comments



http://soapbox.bartsplace.net/article.php/zabbix-sms