📜 ⬆️ ⬇️

Alerts from Zabbix phone call

Hello.
I have been using zabbix for a long time and have been reading habr for a long time.

The idea to teach Zabbiks to speak in a voice visited me for a long time, and even made a system that in a wonderful voice informed night support what happened.
Today I read the post mxx about nagiosʻom on the phone and I was urgently overtaken by the idea of ​​screwing it to my system.

After two and a half hours everything worked, and since in the comments to the original post they requested such a solution, I will post it here.
')


So:
Step number 1 - Prerequisites. We put festival and pjsip
sudo aptitude install festival 


pjsip (see mxx post)

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 - Setting Alerts
First add new alert tool


Then give some user an address (in our case, a cell phone number)


And in the Action settings, register the delivery of an alert to this user with a freshly defined means.


Attention:
* - + sign in the room is important
* - zabbix will speak only the trigger header (accordingly, the title should be informative).
* - in the pjsua settings, set an adequate duration parameter (in order to catch the message 2-3 times in time).
* - Alarms are collected in the pool and then delivered one at a time (1-2 minutes for 1 alarm, when sending to 10 people, the latter will receive a call very late).
* - use dependencies of triggers - otherwise zadolbala calls.
* - only English, Russian can be screwed, but I do not want.
* - it took more time to write the topic than the entire system, if you didn’t notice the welcome comments.

Source: https://habr.com/ru/post/126963/


All Articles