Friday, September 02 2005 @ 05:01 PM CEST Contributed by: bart Views: 8810
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:
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.
The following comments are owned by whomever posted them. This site is not responsible for what they say.
SMS support for Zabbix
Authored by:
Anonymous on
Wednesday, October 12 2005 @ 05:49 PM CEST
Where would one plug in this script? How would zabbix know to call this script? Where would the phone numbers be input in the contact to be fed into the script?
Authored by:
bart on
Wednesday, November 16 2005 @ 06:04 PM CET
In order to get text messages to pagers in the Netherlands you will need to make a few modifications to sms_client and use a script like the this:
#!/usr/local/bin/bash
#
# Zabbix text pager notification script
# (C) 2005 Bart van Leeuwen
#
NUMBER=$1
shift
# Note, messages to text pagers are limited to 80 characters
MSG="$(echo $* | head -c 80 | sed -e $(printf "s/r*//g") )"
echo ${MSG} | /usr/local/bin/sms_client -l 4 kpntap:${NUMBER} >>/var/log/sema_client.log
KPN supports a variety of protocols for sending pager messages, I tested both TAP and UCP. In order for those to work you will have to add 2 lines to the sms_services file and create 2 new service configuration files:
In /usr/local/etc/sms/sms_services you need to add the following:
kpntap = "TAP"
kpnucp = "UCP"
You also have to add two configuration files in /usr/local/etc/sms/services/:
kpntap
# --------------------------------------------------------------------
# Sample SMS resource file for PTT/KPN Telcom (TAP)
# --------------------------------------------------------------------
{
SMS_comms_params = "7E1" # 8 Data, No Parity, 1 Stop Bit
SMS_baud = 19200
# ------------------------------------------------------------
# The SMSCnumber MUST be defined.
# This is the number of your local message center.
# ------------------------------------------------------------
SMS_centre_number = "0665181803" # PTT/KPN Telcom service
# centre number (TAP)
}
# --------------------------------------------------------------------
kpnucp
# --------------------------------------------------------------------
# Sample SMS resource file for PTT/KPN Telcom (UCP)
# --------------------------------------------------------------------
{
SMS_comms_params = "7E1" # 8 Data, No Parity, 1 Stop Bit
SMS_baud = 19200
# ------------------------------------------------------------
# The SMSCnumber MUST be defined.
# This is the number of your local message center.
# ------------------------------------------------------------
SMS_centre_number = "0665181802" # PTT/KPN Telcom service
# centre number (UCP)
}
# --------------------------------------------------------------------
Thanks!