R
R
Rokugo2017-11-21 12:29:11
FreeBSD
Rokugo, 2017-11-21 12:29:11

Zabbix3 notification script not working?

Hello. I made myself a telegram bot that would send notifications in case of problems:

#!/usr/local/bin/bash

TOKEN='something'

if [ $# -ne 3 ] ; then echo 'Error! You must define params' && exit 1 ; fi

CHAT_ID="$1"
SUBJECT="$2"
MESSAGE="$3"

/usr/local/bin/curl --header 'Content-Type: application/json' --request 'POST' --data "{\"chat_id\":\"${CHAT_ID}\",\"text":\"${SUBJECT}\n${MESSAGE}\"}" "https://api.telegram.org/bot$TOKEN/sendMessage"

When started manually, everything works great.
Uncommented the line in the config:
AlertScriptsPath=/usr/local/etc/zabbix3/zabbix/alertscripts
Placed the script there, granted the necessary rights:
-rwxrwxr-x 1 zabbix zabbix 479 Nov 21 13:47 tg-alert.sh
Started a notification method in Zabbix with three passed parameters ({ALERT.SENDTO}, {ALERT.SUBJECT}, {ALERT.MESSAGE}), set a chat-id for the user, set the sending for the necessary triggers.
After the event is triggered, the system reports that the message has been sent, but the bot is silent. I tried to insert a log entry into the script at different stages to determine at what point the stop occurs, but it remains untouched after the alarm is triggered. Those. zabbix did not even try to start it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question