First post from a long time Zabbix user.
I've been looking for a while for a way to send Zabbix notifications from WhatsApp. I struggled to find a simple solution that still worked on Debian 11. I eventually stumbled on a project called Mudslide. I was initially put off by the need for docker/NPM, which I'm not familiar with, but I found pre-compiled binaries which I was able to use. I thought I'd share some notes for anyone who may be interested. Below are my notes using Mudslide with Zabbix 6.4 on Debian 11.
1. Download the pre-compiled binary for mudslide
From https://github.com/robvanderleek/mud...tform-binaries
2. Make executable and move to /usr/local/bin
3. Create alert script.
Our alert script is more complex in order to filter out some notifications. The script hasn't been tested, but it should work.
4. Login to WhatsApp
Command below displays a QR code to login as a linked device.
5. Add media type to Zabbix
Add media type to Zabbix from the WebUI. Alerts > Media types. I cloned the SMS media type and changed the following:
6. Adding media to users
Use the full number with country code for "Send to" when adding media for a user. No preceding 0's or "+". e.g. 442079460000 (UK), 12065550100 (US)
Messages can also be sent to groups. Use the group ID in "Send to". Group IDs can be found from CLI with:
This will fetch the groups the account is currently a member of.
Note on the cache folder:
The Zabbix user on our system does not have a home folder, so we use /tmp/mudslide-cache for the cache folder. The cache contains login information. /tmp is cleared on reboot so you'll need to login on each reboot or change the cache folder. The cache folder does need to be writeable by the Zabbix user. I work around this I sync the folder to another location with cron:
Hope this has been useful.
I've been looking for a while for a way to send Zabbix notifications from WhatsApp. I struggled to find a simple solution that still worked on Debian 11. I eventually stumbled on a project called Mudslide. I was initially put off by the need for docker/NPM, which I'm not familiar with, but I found pre-compiled binaries which I was able to use. I thought I'd share some notes for anyone who may be interested. Below are my notes using Mudslide with Zabbix 6.4 on Debian 11.
1. Download the pre-compiled binary for mudslide
From https://github.com/robvanderleek/mud...tform-binaries
Code:
wget https://github.com/robvanderleek/mudslide/releases/download/0.25.1/mudslide-linuxstatic-x64
Code:
chmod +x mudslide-linuxstatic-x64 mv mudslide-linuxstatic-x64 /usr/local/bin/mudslide
Our alert script is more complex in order to filter out some notifications. The script hasn't been tested, but it should work.
Code:
vi /usr/lib/zabbix/alertscripts/whatsapp
Code:
#!/bin/bash mudslide -c /tmp/mudslide-cache send $1 "$2"
Code:
chmod +x /usr/lib/zabbix/alertscripts/whatsapp
Command below displays a QR code to login as a linked device.
Code:
sudo -u zabbix mudslide -c /tmp/mudslide-cache login
Add media type to Zabbix from the WebUI. Alerts > Media types. I cloned the SMS media type and changed the following:
Code:
Name: WhatsApp Type: Script Script name: whatsapp
Use the full number with country code for "Send to" when adding media for a user. No preceding 0's or "+". e.g. 442079460000 (UK), 12065550100 (US)
Messages can also be sent to groups. Use the group ID in "Send to". Group IDs can be found from CLI with:
Code:
sudo -u zabbix mudslide -c /tmp/mudslide-cache groups
Note on the cache folder:
The Zabbix user on our system does not have a home folder, so we use /tmp/mudslide-cache for the cache folder. The cache contains login information. /tmp is cleared on reboot so you'll need to login on each reboot or change the cache folder. The cache folder does need to be writeable by the Zabbix user. I work around this I sync the folder to another location with cron:
Code:
vi /usr/local/bin/mudslide-cache-sync.sh
Code:
#!/bin/bash # This script syncs the mudslide cache from /tmp to /var/cache. This is to work around the cache being cleared every time the server is rebooted. # First rsync files from the backup to the cache. "-u" prevents overwriting newer files. This will also recreate the folder if it has been removed. rsync -quazvh --copy-as=zabbix:zabbix /var/cache/mudslide/* /tmp/mudslide-cache/ # Then sync any updated files from the cache to the back-up. rsync -qazvh /tmp/mudslide-cache/* /var/cache/mudslide/
Code:
chmod +x /usr/local/bin/mudslide-cache-sync.sh cd /etc/cron.hourly ln -s /usr/local/bin/mudslide-cache-sync.sh mudslide-cache-sync
Comment