mirror of
https://gitlab.sectorq.eu/jaydee/zabbix-gotify.git
synced 2025-12-13 18:24:53 +01:00
45 lines
881 B
Bash
45 lines
881 B
Bash
#!/bin/bash
|
|
echo "checking curl package"
|
|
if [[ `apk info -vv | egrep '^curl'` ]]
|
|
then
|
|
echo "Package ok"
|
|
else
|
|
echo "Installing..."
|
|
apk add curl
|
|
fi
|
|
# Gotify-Server URL (IP or FQDN)
|
|
GOTIFY_URL="https://gotify.sectorq.eu"
|
|
|
|
# Zabbix Parameter
|
|
GOTIFY_TOKEN=$1
|
|
SUBJECT=$2
|
|
MESSAGE=$3
|
|
SEVERITY=$4
|
|
|
|
# Converting Zabbix issue level to Gotify priority
|
|
case $SEVERITY in
|
|
"Disaster")
|
|
PRIORITY=10
|
|
;;
|
|
"High")
|
|
PRIORITY=8
|
|
;;
|
|
"Average")
|
|
PRIORITY=5
|
|
;;
|
|
"Warning")
|
|
PRIORITY=3
|
|
;;
|
|
"Information")
|
|
PRIORITY=0
|
|
;;
|
|
"Not classified")
|
|
PRIORITY=0
|
|
;;
|
|
*)
|
|
PRIORITY=1 # Default value for undefined severity
|
|
;;
|
|
esac
|
|
|
|
# Sending the message to Gotify
|
|
curl -X POST "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" -F "title=$SUBJECT" -F "message=$MESSAGE" -F "priority=$PRIORITY" |