Zabbix and XMPP alerts
Zabbix should theoretically be able out of the box to send alerts via XMPP.
For some reason this functionality does not work as intended, luckily it is
possible to specify a custom script to send alerts; combining the
aforementioned script with the Perl library sendxmpp is the easiest way to
enable Zabbix from sending notifications via XMPP.
$ yum install sendxmpp
Create a bash script, this will be invoked by Zabbix to send notifications:
$ vi /usr/lib/zabbix/alertscripts/sendxmpp.sh
---
#!/bin/sh
echo “$3” | /usr/bin/sendxmpp -u <sender_user> -j <sender_domain> -p <sender_user_password> -s “$2” -i "$1" -t
---
Change file ownership and permissions accordingly
$ chown zabbix:zabbix /usr/lib/zabbix/alertscripts/sendxmpp.sh
$ chmod 755 /usr/lib/zabbix/alertscripts/sendxmpp.sh
Three more steps are needed, those can be performed directly inside Zabbix’s web GUI:
Navigate
Adminstration
->Media Types
, create a new one withType
set toscript
,Script
set tosendxmpp.sh
and three parameters:{ALERT.SENDTO}
,{ALERT.SUBJECT}
,{ALERT.MESSAGE}
.
Those three parameter will be used as CLI arguments for the BASH script.While still being in
Adminstration
->Media Types
page, select tabMessage templates
and add a few templates for the events you wanna be notified about.Navigate
Configuration
->Actions
, click onReport problems to Zabbix administrators
and make sure it is enabled.Navigate
Configuration
->Users
, click on a username, navigate to theMedia
tab, add a new one and specify the receiver XMPP address.
You should now receive XMPP notifications.
Updated on 29 January 2021 - Zabbix 5 LTS