Skip to content

Working with Zabbix 3.0

Ilya Ableev edited this page Feb 20, 2016 · 1 revision

General changes

In previous releases every alert script had hard way to pass parameters from zabbix to it. There was $1 is to field, $2 is subject and $3 is body. Since Zabbix version 3.0 you need to add all parameters manually: https://www.zabbix.com/documentation/3.0/manual/config/notifications/media/script

So the settings should be changed to

And it is not everything.

Group notifications

As it has been said, you have ability to pass a lot of parameters to your custom alert script. So now there is no need to use zbxtg_group.py anymore, just add fourth parameter --group

And it will be useful for command line: python zbxtg.py "Zabbix in Telegram" ololo ololo --group

Debug

Every message sent from zabbix can be stored in zabbix_server.log, just place additional parameter --debug into the settings:

appliance@zabbix:/var/log/zabbix$ grep zbxtg.py zabbix_server.log
  2655:20160220:032003.419 In zbx_popen() command:'/usr/lib/zabbix/alertscripts/zbxtg.py 'ableev' 'PROBLEM: echo 0' 'Trigger: echo 0
  2655:20160220:032004.025 zbxtg.py output:
zbxtg.py: {u'ok': True, u'result': {u'username': u'ZabbixDevBot', u'first_name': u'Zabbix Bot', u'id': 101740052}}
zbxtg.py: Cache file with uids: /tmp/zbxtg/uids.txt
zbxtg.py: Telegram uid of private 'ableev': 6931850
zbxtg.py: Trying to /sendMessage:
zbxtg.py: https://api.telegram.org/botXXX/sendMessage
zbxtg.py: post params: {'text': 'PROBLEM: echo 0\nTrigger: echo 0\nTrigger status: PROBLEM\nTrigger severity: Disaster\nTrigger URL: \n\nItem values:\n\n1. echo_0 (Zabbix server:system.run["echo 0"]): 0\n2. *UNKNOWN* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN*\n3. *UNKNOWN* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN*\n\nOriginal event ID: 55', 'parse_mode': 'Markdown', 'chat_id': '6931850\n'}
zbxtg.py: {u'error_code': 400, u'ok': False, u'description': u"[Error]: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 119"}
  2655:20160220:032004.029 In zbx_popen() command:'/usr/lib/zabbix/alertscripts/zbxtg.py 'Test-Zabbix-in-Telegram' 'PROBLEM: echo 0' 'Trigger: echo 0
  2655:20160220:032004.403 zbxtg.py output:
zbxtg.py: {u'error_code': 400, u'ok': False, u'description': u"[Error]: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 119"}

Probably you need to set DebugLevel to 4 in zabbix_server.conf to see logs.