Answer the question
In order to leave comments, you need to log in
Why doesn't Zabbix 3.0 pass parameters $1,$2,$3 to the script?
There is Zabbix 3.0 on Ubuntu 14.04. Got an API from SMS.RU to send SMS.
Created a script in /usr/local/share/zabbix/alertscripts. Here is the content of the script:
#!/bin/bash
# SMS.RU sender for zabbix
api="133C1FB3-8D01-DD1C-90BA-********"
to="$1"
subject="$2"
body="$3"
curl -d "text=$body" http://sms.ru/sms/send\?api_id=$api\&to=$to
Answer the question
In order to leave comments, you need to log in
Problem solved! The problem was that I ran the script from under the bash and, accordingly, it did not receive parameters from Zabbix (because I used the bash standard input / output stream). For performance, it was necessary to initiate the execution of the script by Zabbix or add variables when executing the script in the bash. For Zabbix 3.0 it was easy to add {ALERT.SENDTO}, {ALERT.SUBJECT}, {ALERT.MESSAGE} values in Media Types to your script.
And why did you put the parameters in quotation marks?to="$1" => to=$1
Maybe someone will need my version of the script for sending through the site sms.ru
#!/bin/bash
# SMS.RU
#Задаём переменные
api="Тут должен быть API"
phone="$1"
text="$2"
body="$3"
LOG="/var/log/zabbix/SMS.log"
# Делаем запись даты в лог
echo >> $LOG
echo -e " \e[1;32m --=START=--\e[m" >> $LOG
echo >> $LOG
echo -e " \e[1;33m -=`date`=-\e[0m" >> $LOG
echo >> $LOG
#Записываем в лог, что передаёт ZABBIX в скрипт.
echo " Заголовок сообщения" >> $LOG
echo -e "\e[1;36m $body\e[0m" >> $LOG
echo " Текст сообщения" >> $LOG
echo -e "\e[1;36m $text\e[0m" >> $LOG
echo " Телефон получателя" >> $LOG
echo -e "\e[1;36m $phone\e[0m" >> $LOG
echo >> $LOG
#Посылаем СМС
curl -d "text=$body" http://sms.ru/sms/send\?api_id=$api\&to=$phone >> $LOG
echo -e "\e[1;34m <-ответ от СМС шлюза\e[0m" >> $LOG
echo >> $LOG
echo -e " \e[1;31m --=FINISH=--\e[m" >> $LOG
echo"===================================================================================================================" >> $LOG
#Смотреть логи в цветном виде можно командой вида : tail -n 19 *Путь к файлу*.log
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question