Alerts from Zabbix by phone call
Hello.
I have been using zabbix for a long time and have been reading Habr for a long time.
The idea of teaching Zabbix to speak in a voice has been visiting me for a long time, and even made a system that in a wonderful voice informed the night support what happened.
Today I read the mxx post about nagios by phone and I was immediately overtaken by the thought of screwing this to my system.
After two and a half hours everything worked, and since they asked for such a solution in the comments on the original post, I will publish it here.
So:
Step # 1 - Prerequisites. We put festival and pjsip
pjsip (see post mxx )
Step # 2 - Config zabbix_server
Step number 3 - zabbiksa scripts
Step №4 - Configuring alerts
First add a new alert tool
Then give the user an address (in our case, mobile number)
And in the Action settings, specify the delivery of the alert to this user with a freshly defined tool.
Attention:
* - the + sign in the number is important
* - zabbix will only speak the trigger header (accordingly, the header should be meaningful).
* - in the pjsua settings set an adequate duration parameter (in order to have time to listen to the message 2-3 times).
* - alarms are collected in a pool and then delivered one at a time (1-2 minutes for 1 alarm, when sending to 10 people, the latter will receive the call very late).
* - use the dependencies of triggers - otherwise it is a bit annoying to call.
* - only English, Russian can be screwed, but I do not want.
* - it took more time to write the topic than the whole system, if you haven’t noticed, welcome to the comments.
I have been using zabbix for a long time and have been reading Habr for a long time.
The idea of teaching Zabbix to speak in a voice has been visiting me for a long time, and even made a system that in a wonderful voice informed the night support what happened.
Today I read the mxx post about nagios by phone and I was immediately overtaken by the thought of screwing this to my system.
After two and a half hours everything worked, and since they asked for such a solution in the comments on the original post, I will publish it here.
So:
Step # 1 - Prerequisites. We put festival and pjsip
sudo aptitude install festival
pjsip (see post mxx )
Step # 2 - Config zabbix_server
zabbix@zabbix-new:~$ grep AlertScript /etc/zabbix/zabbix_server.conf
### Option: AlertScriptsPath
AlertScriptsPath=/home/zabbix/bin/
Step number 3 - zabbiksa scripts
zabbix@zabbix-new:~$ cat /home/zabbix/bin/sipalarm
#!/bin/bash
HOME=/home/zabbix
SPOOL=$HOME/spool
STAMP=`date +%s`
add_to_spool () {
text2wave <(echo $2) > $SPOOL/$STAMP$1.wav
}
add_to_spool "$1" "$2"
$HOME/bin/sipnd &
zabbix@zabbix-new:~$ cat /home/zabbix/bin/sipnd
#!/bin/bash
HOME=/home/zabbix
SPOOL=$HOME/spool
die () {
echo "$1"
exit 0
}
check_lock () {
test -e $HOME/sipnd.lock && die "already running"
}
get_lock () {
echo $$ > $HOME/sipnd.lock
}
drop_lock () {
rm $HOME/sipnd.lock
}
check_lock; get_lock
for i in $SPOOL/*.wav; do
TMP=${i##*+}
PHONE=+${TMP%%.wav}
echo "DEBUG: pjsua --config-file=/etc/pjsua.cfg --play-file=$i sip:$PHONE@sipnet.ru --auto-play"
( sleep 60 && echo q ) | pjsua --config-file=/etc/pjsua.cfg --play-file=$i sip:$PHONE@sipnet.ru --auto-play
wait
rm $i
done
drop_lock
Step №4 - Configuring alerts
First add a new alert tool
Then give the user an address (in our case, mobile number)
And in the Action settings, specify the delivery of the alert to this user with a freshly defined tool.
Attention:
* - the + sign in the number is important
* - zabbix will only speak the trigger header (accordingly, the header should be meaningful).
* - in the pjsua settings set an adequate duration parameter (in order to have time to listen to the message 2-3 times).
* - alarms are collected in a pool and then delivered one at a time (1-2 minutes for 1 alarm, when sending to 10 people, the latter will receive the call very late).
* - use the dependencies of triggers - otherwise it is a bit annoying to call.
* - only English, Russian can be screwed, but I do not want.
* - it took more time to write the topic than the whole system, if you haven’t noticed, welcome to the comments.