All Projects → ericoc → Zabbix Slack Alertscript

ericoc / Zabbix Slack Alertscript

Licence: mit
Zabbix AlertScript for Slack.com chat

Programming Languages

shell
77523 projects
bash
514 projects

Projects that are alternatives of or similar to Zabbix Slack Alertscript

pr-reviews-reminder-action
A GitHub Action to send Slack/Teams notification for Pull Request that are waiting for reviewers.
Stars: ✭ 18 (-95.57%)
Mutual labels:  slack, webhook
Alertmanager
Prometheus Alertmanager
Stars: ✭ 4,574 (+1026.6%)
Mutual labels:  slack, monitoring
zoom-slack-status-updater
Update your Slack status automatically when you join a Zoom meeting.
Stars: ✭ 23 (-94.33%)
Mutual labels:  slack, webhook
Hooka
😎 A webhook server with zero coding
Stars: ✭ 180 (-55.67%)
Mutual labels:  webhook, slack
Chronos
📊 📊 📊 Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.
Stars: ✭ 347 (-14.53%)
Mutual labels:  slack, monitoring
alerta-contrib
Contributed integrations, plugins and custom webhooks
Stars: ✭ 107 (-73.65%)
Mutual labels:  webhook, zabbix
SlackWebhooksGithubCrawler
Search for Slack Webhooks token publicly exposed on Github
Stars: ✭ 21 (-94.83%)
Mutual labels:  slack, webhook
Slacknimate
👯 Realtime text animation for Slack chatops
Stars: ✭ 250 (-38.42%)
Mutual labels:  slack, monitoring
Kube Slack
Kubernetes Slack Monitoring
Stars: ✭ 321 (-20.94%)
Mutual labels:  slack, monitoring
Amazon Alert
Track prices on Amazon and receive email alerts for price drops
Stars: ✭ 290 (-28.57%)
Mutual labels:  monitoring, alerts
Tradingview Webhook Bot
⚙️ Send TradingView alerts to Telegram, Discord, Slack, Twitter and/or Email.
Stars: ✭ 135 (-66.75%)
Mutual labels:  webhook, slack
Squzy
Squzy - is a high-performance open-source monitoring, incident and alert system written in Golang with Bazel and love.
Stars: ✭ 359 (-11.58%)
Mutual labels:  monitoring, zabbix
Rust Slack
A rust crate for sending messages to Slack via webhooks
Stars: ✭ 128 (-68.47%)
Mutual labels:  webhook, slack
notify
推送通知 sdk(Bark、Chanify、钉钉群机器人、Discord、邮件、飞书群机器人、Gitter、Google Chat、iGot、Logger、Mattermost、Now Push、PushBack、Push、PushDeer、PushPlus、QQ 频道机器人、Rocket Chat、Server 酱、Showdoc Push、Slack、Telegram、Webhook、企业微信群机器人、息知、Zulip)。
Stars: ✭ 335 (-17.49%)
Mutual labels:  slack, webhook
Prom2teams
prom2teams is an HTTP server built with Python that receives alert notifications from a previously configured Prometheus Alertmanager instance and forwards it to Microsoft Teams using defined connectors
Stars: ✭ 122 (-69.95%)
Mutual labels:  webhook, monitoring
iris
Watch on Kubernetes events, filter and send them as standard wehbook to any system
Stars: ✭ 57 (-85.96%)
Mutual labels:  slack, webhook
Zabbix Notify
Notify alarms from Zabbix to Slack Hipchat and PagerDuty
Stars: ✭ 139 (-65.76%)
Mutual labels:  slack, zabbix
Slack Watchman
Monitoring your Slack workspaces for sensitive information
Stars: ✭ 159 (-60.84%)
Mutual labels:  slack, monitoring
terraform-aws-ecs-cloudwatch-sns-alarms
Terraform module to create CloudWatch Alarms on ECS Service level metrics.
Stars: ✭ 23 (-94.33%)
Mutual labels:  slack, alerts
Awesome Monitoring
INFRASTRUCTURE、OPERATION SYSTEM and APPLICATION monitoring tools for Operations.
Stars: ✭ 356 (-12.32%)
Mutual labels:  monitoring, zabbix

Zabbix Slack AlertScript

About

This is simply a Bash script that uses the custom alert script functionality within Zabbix along with the incoming web-hook feature of Slack. I originally created this since I could not find any already existing/similar scripts at the time. This is one of many now.

Versions

This works with Zabbix 1.8 or greater - including 2.x and 3.x, as well as the newest 4.0 and 4.2 versions!

4.4

The latest version of Zabbix (4.4) has included its own built-in webhook media type which is documented here:

Official Zabbix Documentation 4.4 > Media Types > Webhook

The Zabbix 4.4 webhook documentation includes a specific example of how to set up Slack webhook notifications with their new included feature.

Thanks

Huge thanks and appreciation to every one who has submitted issues or pull requests including:

  • Paul Reeves for the hint that Slack changed their API/URLs!
  • Igor Shishkin for the ability to message users as well as channels!
  • Leslie at AspirationHosting for confirming that this script worked on Zabbix 1.8.2!
  • Hiromu Yakura for escaping quotation marks in the fields received from Zabbix to have valid JSON!
  • Devlin Gonçalves, tkdywc, damaarten, and lunchables for Zabbix 3.0 AlertScript documentation, suggestions and testing!

Installation

The script itself

This slack.sh 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:

[[email protected] ~]# grep AlertScriptsPath /etc/zabbix/zabbix_server.conf
### Option: AlertScriptsPath
AlertScriptsPath=/usr/local/share/zabbix/alertscripts

[[email protected] ~]# ls -lh /usr/local/share/zabbix/alertscripts/slack.sh
-rwxr-xr-x 1 root root 1.4K Dec 27 13:48 /usr/local/share/zabbix/alertscripts/slack.sh

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

Configuration

Slack.com web-hook

An incoming web-hook integration must be created within your Slack.com account which can be done at https://my.slack.com/services/new/incoming-webhook as shown below:

Slack.com Incoming Web-hook Integration

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

https://hooks.slack.com/services/QW3R7Y/D34DC0D3/BCADFGabcDEF123

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

# Slack incoming web-hook URL and user name
url='https://hooks.slack.com/services/QW3R7Y/D34DC0D3/BCADFGabcDEF123'
username='Zabbix'

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: slack.sh

...and ensure that it is enabled before clicking "Save", like so:

Old 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 slack.sh script. On Zabbix 3.x and 4.x, three script parameters should be added as follows:

  • {ALERT.SENDTO}
  • {ALERT.SUBJECT}
  • {ALERT.MESSAGE}

...as shown here:

Zabbix Media Type

An optional fourth script parameter can be added to over-ride the url value that is hard-coded in the slack.sh script. This makes it possible to re-use the script for multiple Slack teams.

An optional fifth script parameter can be added for proxy support. You can supply a host:port value (such as example.com:8080) that will be used when connecting to the Slack.com web-hook URL.

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 Slack.com 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. You can stick with the default subject and message text for your problem (and optional recovery) operations.

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.

Testing

The new Testing media types feature within Zabbix 4.2 should allow you to test sending messages to Slack:

Zabbix Media Type Test

Zabbix Media Type Test Message

Alternatively, you can execute the script manually (as opposed to via Zabbix) from Bash on a terminal:

$ bash slack.sh '@ericoc' 'Problem: This is a test' 'This is a test of something being wrong!'

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.sh:

Slack Terminal Example Message

More Information

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].