Zabbix Alert Notification Script for Slack. by pure python.
Can use by “Remote command”. But can’t use by “Media type”.
if use by python2.6 (like CentOS6.x), install argparse module. ex,
$ sudo yum install python-argparse
Screenshot
Notification example.
Install
In your zabbix server,
$ pip install zbx2slack
or you can download directly using wget, curl.
$ wget https://raw.githubusercontent.com/laughk/zbx2slack/master/zbx2slack.py
$ chmod +x zbx2slack.py
(if necessary, use sudo. )
set this script your zabbix server.
put file and add mode to execute.
Usage
get incoming-webhook url for your slack. from incoming webhook integration.
In the WebUI of your zabbix server.
[Configureation]
[Action]
Choose ‘Trigger’ at Event source and Create Action.
if “Recovery message” checked, Uncheck the checkbox.
- At [Conditions] tab, add Trigger value = OK to Conditions.
Trigger value = OK and Trigger value = PROBLEM are in Conditions.
- At [Operations] tab, add Remote Command
Operation type : Remote Command
Targeta list : any host (ex. Current host)
Type : Custom script
Execute on : Zabbix server
Commands:
(if directly download, replace zbx2slack to zbx2slack.py.)
zbx2slack \ --zabbix-server-url "http://zabbix.example.com/zabbix" \ --slack-botname "Zabbix Alert" \ --slack-incoming-webhook-url "https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxx/...." \ --trigger-id "{TRIGGER.ID}" \ --trigger-name "{TRIGGER.NAME}" \ --trigger-status "{TRIGGER.STATUS}" \ --trigger-severity "{TRIGGER.SEVERITY}" \ --event-id "{EVENT.ID}" \ --item "{HOST.NAME1}|{ITEM.NAME1}|{ITEM.KEY1}|{ITEM.VALUE1}|{ITEM.ID1}" \ --item "{HOST.NAME2}|{ITEM.NAME2}|{ITEM.KEY2}|{ITEM.VALUE2}|{ITEM.ID2}" \ --item "{HOST.NAME3}|{ITEM.NAME3}|{ITEM.KEY3}|{ITEM.VALUE3}|{ITEM.ID3}"
LICENSE
MIT
Release files for zbx2slack 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zbx2slack-0.1.1.tar.gz | 4.1 kB | Details |
Release files / zbx2slack-0.1.1.tar.gz
| Download URL | zbx2slack-0.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb980ebcf85c03979e66456e4797d674677c68453cdfce0e53a0222f31ad84f2
|
|
BLAKE2b-256 checksum How to use checksums |
cf3bc859681791c17a0c2114a83ff21c19d4613246a85d1b8b31791ac264149c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |