Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Latest commit

 

History

History
65 lines (42 loc) · 3.44 KB

README.md

File metadata and controls

65 lines (42 loc) · 3.44 KB

Zabbix Microsoft Teams 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 Microsoft Teams It is heavily based on the previous Zabbix Slack alert script here: https://github.com/ericoc/zabbix-slack-alertscript

Versions

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

Huge thanks and appreciation to:

  • Eric OC for the original script on which this modification is based

Installation (work in progress)

The script itself

This teams.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:

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

[root@zabbix ~]# chmod +x /usr/local/share/zabbix/alertscripts/teams.sh

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

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

Configuration

MS Teams web-hook

An incoming web-hook integration must be created within your Teams account:

https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using

Within the Zabbix web interface

When logged in to the Zabbix servers web interface with super-administrator privileges, you need to create an action on the "Actions" sub-tab of the "Configuration" tab within the Zabbix servers web interface. Give it a name and click enable to activate the script. Choose "Operations" tab and click New in Operations area. Choose "Run command" in "Operation type" dropdown. In target list add "Current host". Select "Custom script" as type. Select to "Execute on" "Zabbix server (proxy)". In "Command" textarea paste:

/bin/bash /usr/lib/zabbix/alertscripts/teams.sh "{EVENT.SEVERITY}" "{HOST.NAME}" "{EVENT.NAME}" "{EVENT.TIME}" "{EVENT.DATE}" "{EVENT.ID}" "{TRIGGER.ID}" "{EVENT.STATUS}"

Click the "Update"-link and repeat these final steps for "Recovery operations" and "Update operations" tabs. Click the "Update" button on the buttom to save your work.

Testing

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

$ bash teams.sh 'Critical' 'Testhost' 'Nothing is wrong. This is just a test' '00:00:00' '01.01.2020' '1234' '4321' 'PROBLEM'

More Information