Zabbix2Ntfy/ntfy.sh

51 lines
861 B
Bash

#!/bin/bash
# Script de notification Ntfy pour Zabbix
# Version 0.3
# Paramètres personnalisables
# Ntfy
ntfy_user="USER"
ntfy_password="PASSWORD"
# Carte réseau
address_interface="172.17.17.18"
# Proxy
# Adresse + port du proxy (1.2.3.4:1234)
proxy_address="172.17.0.1:3128"
proxy_user="USER"
proxy_password="PASSWORD"
#=================================================================================
# Script
topic=$1
subject=$2
body=$3
if [ ! "$(grep "Problème" <<<"$subject")" = "" ]
then
#Problème
tag="facepalm"
elif [ ! "$(grep "Resolus" <<<"$subject")" = "" ]
then
#Résolu
tag="+1"
fi
curl \
-x "http://$proxy_user:$proxy_password@$proxy_address" \
-interface $address_interface \
-u $ntfy_user:$ntfy_password \
-H "Title: $subject" \
-H "Tags: $tag" \
-d "$body" \
https://ntfy.axolito.fr/$topic
exit 0