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
This works with Zabbix 1.8.x or greater - including 2.2, 2.4, 3.x and 4.x!
- Eric OC for the original script on which this modification is based
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.
An incoming web-hook integration must be created within your Teams account:
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.
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'