Notify alarms from Zabbix to Slack

This is simply a Bash script that uses the custom alert script functionality within Zabbix along with the incoming web-hook feature of Slack that I got a chance to write since I could not find any already existing/similar scripts.


This works with Zabbix 1.8.x or greater – including 2.2, 2.4, 3.x. and 4.x!


The script itself

This script needs to be placed in the AlertScriptsPath directory that is specified within the Zabbix servers’ configuration file (zabbix_server.conf) and must be executable by the user running the zabbix_server binary (usually “zabbix”) on the Zabbix server:

Download script in git :

[root@zabbix ~]

# ls -lh /usr/local/share/zabbix/alertscripts/ -rwxr-xr-x 1 root root 1.4K Dec 27 13:48 /usr/local/share/zabbix/alertscripts/

If you do change AlertScriptsPath (or any other values) within zabbix_server.conf, a restart of the Zabbix server software is required.

Configuration web-hook

An incoming web-hook integration must be created within your account which can be done at as shown below: Incoming Web-hook Integration

Given the above screenshot, the incoming web-hook URL would be:

Make sure that you specify your correct incoming web-hook URL and feel free to edit the sender user name at the top of the script:

Within the Zabbix web interface

When logged in to the Zabbix servers web interface with super-administrator privileges, navigate to the “Administration” tab, access the “Media Types” sub-tab, and click the “Create media type” button.

You need to create a media type as follows:

  • Name: Slack
  • Type: Script
  • Script name:

…and ensure that it is enabled before clicking “Save”, like so:

Zabbix Media Type

However, on Zabbix 3.x and greater (including 4.x), media types are configured slightly differently and you must explicity define the parameters sent to the script. On Zabbix 3.x and 4.x, three script parameters should be added as follows:


…as shown here:

Zabbix 3.x Media Type

An optional 4th script parameter can be added to override the url hardcoded in the script with the incoming web-hook URL. This makes it possible to reuse the script for a different user or group to be alerted in a seperate slack environment. An optional 5th script parameter can be added to add proxy support. use an url:port combination to specify the proxy.

Then, create a “Slack” user on the “Users” sub-tab of the “Administration” tab within the Zabbix servers web interface and specify this users “Media” as the “Slack” media type that was just created with the channel (“#alerts” in the example) or user name (such as “@ericoc”) that you want messages to go to in the “Send to” field as seen below:

Zabbix User

Finally, an action can then be created on the “Actions” sub-tab of the “Configuration” tab within the Zabbix servers web interface to notify the Zabbix “Slack” user ensuring that the “Subject” is “PROBLEM” for “Default message” and “RECOVERY” should you choose to send a “Recovery message”.

Keeping the messages short is probably a good idea; use something such as the following for the contents of each message:

Additionally, you can have multiple different Zabbix users each with “Slack” media types that notify unique Slack users or channels upon different triggered Zabbix actions.

If you are interesting in longer notification messages (with line breaks for example), you may want to reference this pull request or any number of forks of this repository.


Assuming that you have set a valid Slack web-hook URL within your “” file, you can execute the script manually (as opposed to via Zabbix) from Bash on a terminal:

Alerting a specific user name results in the message actually coming from the “slackbot” user using a sort-of “spoofed” user name within the message. A channel alert is sent as you would normally expect from whatever user name you specify in “”:

Slack Testing

source :

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Site Footer