Bash script which allows to send messages to Slack via Incoming Webhooks app. You can use it to send messages directly from console or from Zabbix.
- Zabbix version >=
3.X
curl
is installed in your system:which curl
./slack.sh --webhook https://hooks.slack.com/services/XXX/YYYY/ZZZZ --message "Message" --severity 3 --title 'Title' --description 'Some Description' --username 'James Bond'
Parameters list: --webhook (-w) Web-hook URL --message (-m) Message text (optional) --severity (-s) Numerical trigger severity. Possible values: 0 - Not classified, 1 - Information, 2 - Warning, 3 - Average, 4 - High, 5 - Disaster (optional) --title (-t) Message title (optional) --description (-d) Message description (optional) --username (-u) Username to be displayed (optional) --color (-c) Message color: blue, yellow, orange, light_red, red, green (optional)
- Install Incoming Webhooks app to your channel in Slack
- After installation you will get a webhook URL. You will need it later
- Deploy
slack.sh
script to AlertScripts folderIf you are using
Docker
you can install Zabbix from Docker Image: https://hub.docker.com/r/spoonest/zabbix-appliance-with-slack/- By default the folder path is
/usr/local/share/zabbix/alertscripts
- Make sure the script is executable:
chmod +x /path/to/slack.sh
- By default the folder path is
- Create new Media Type in Zabbix: Administration > Media Types
- Create new User Group in Zabbix: Administration > User groups
- Create new User in Zabbix: Administration > Users
I prefer to create 2 users: slack_critical - for important notifications from Zabbix (Average, High, Disaster), and slack_not_important - for others (Not classified, Information, Warning).
- Create new Action in Zabbix: Configuration > Actions
-
Action tab:
-
Operations Tab:
- Default subject:
{TRIGGER.SEVERITY}: {HOSTNAME}: {TRIGGER.NAME}
- Default message:
Problem started at {EVENT.TIME} on {EVENT.DATE} Problem name: {TRIGGER.NAME} Host: {HOST.NAME} ({IPADDRESS}) Severity: {TRIGGER.SEVERITY}
Original problem ID: {EVENT.ID} {TRIGGER.URL}
- Operations:
- Default subject:
-
Recovery Operations Tab:
- Default subject:
Resolved: {HOSTNAME}: {TRIGGER.NAME}
- Default message:
Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE} Problem name: {TRIGGER.NAME} Host: {HOST.NAME} ({IPADDRESS}) Severity: {TRIGGER.SEVERITY}
Original problem ID: {EVENT.ID} {TRIGGER.URL}
- Operations:
- Default subject:
-
Acknowledgement Operations Tab:
-
- Done! You will receive notifications from Zabbix to Slack