]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - flakes/private/monitoring/plugins/notify_by_apprise
Squash changes containing private information
[perso/Immae/Config/Nix.git] / flakes / private / monitoring / plugins / notify_by_apprise
CommitLineData
1a64deeb
IB
1#!/usr/bin/env bash
2
3APPRISE_USERNAME="Naemon"
4APPRISE_USERICON="https://assets.immae.eu/monitoring.png"
5APPRISE_URLS=$(echo "$2" | sed -e "s/{username}/$APPRISE_USERNAME/g" -e "s@{image_url}@$APPRISE_USERICON@g")
6
7if [ "$SERVICESTATE" = "CRITICAL" ]; then
8 ICON="❗"
9elif [ "$SERVICESTATE" = "WARNING" ]; then
10 ICON="⚠️:"
11elif [ "$SERVICESTATE" = "OK" ]; then
12 ICON="✅"
13elif [ "$SERVICESTATE" = "UNKNOWN" ]; then
14 ICON="❓"
15elif [ "$HOSTSTATE" = "UP" ]; then
16 ICON="✅"
17elif [ "$HOSTSTATE" = "DOWN" ]; then
18 ICON="❗"
19elif [ "$HOSTSTATE" = "UNKNOWN" ]; then
20 ICON="❓"
21elif [ "$HOSTSTATE" = "UNREACHABLE" ]; then
22 ICON="❓"
23else
24 ICON="◻"
25fi
26
27if [ "$1" = "host" ]; then
28 apprise --title "${ICON} ${NOTIFICATIONTYPE} ${HOST} is ${HOSTSTATE}" --body "$HOSTOUTPUT" $APPRISE_URLS
29else
30 apprise --title "${ICON} ${NOTIFICATIONTYPE} ${SERVICEDESC} on ${HOST} is ${SERVICESTATE}" --body "$SERVICEOUTPUT" $APPRISE_URLS
31fi