diff options
Diffstat (limited to 'flakes/private/monitoring/plugins/notify_by_apprise')
-rwxr-xr-x | flakes/private/monitoring/plugins/notify_by_apprise | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/flakes/private/monitoring/plugins/notify_by_apprise b/flakes/private/monitoring/plugins/notify_by_apprise new file mode 100755 index 0000000..82bc5a3 --- /dev/null +++ b/flakes/private/monitoring/plugins/notify_by_apprise | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | APPRISE_USERNAME="Naemon" | ||
4 | APPRISE_USERICON="https://assets.immae.eu/monitoring.png" | ||
5 | APPRISE_URLS=$(echo "$2" | sed -e "s/{username}/$APPRISE_USERNAME/g" -e "s@{image_url}@$APPRISE_USERICON@g") | ||
6 | |||
7 | if [ "$SERVICESTATE" = "CRITICAL" ]; then | ||
8 | ICON="❗" | ||
9 | elif [ "$SERVICESTATE" = "WARNING" ]; then | ||
10 | ICON="⚠️:" | ||
11 | elif [ "$SERVICESTATE" = "OK" ]; then | ||
12 | ICON="✅" | ||
13 | elif [ "$SERVICESTATE" = "UNKNOWN" ]; then | ||
14 | ICON="❓" | ||
15 | elif [ "$HOSTSTATE" = "UP" ]; then | ||
16 | ICON="✅" | ||
17 | elif [ "$HOSTSTATE" = "DOWN" ]; then | ||
18 | ICON="❗" | ||
19 | elif [ "$HOSTSTATE" = "UNKNOWN" ]; then | ||
20 | ICON="❓" | ||
21 | elif [ "$HOSTSTATE" = "UNREACHABLE" ]; then | ||
22 | ICON="❓" | ||
23 | else | ||
24 | ICON="◻" | ||
25 | fi | ||
26 | |||
27 | if [ "$1" = "host" ]; then | ||
28 | apprise --title "${ICON} ${NOTIFICATIONTYPE} ${HOST} is ${HOSTSTATE}" --body "$HOSTOUTPUT" $APPRISE_URLS | ||
29 | else | ||
30 | apprise --title "${ICON} ${NOTIFICATIONTYPE} ${SERVICEDESC} on ${HOST} is ${SERVICESTATE}" --body "$SERVICEOUTPUT" $APPRISE_URLS | ||
31 | fi | ||