diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 01:35:06 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 02:11:48 +0200 |
commit | 1a64deeb894dc95e2645a75771732c6cc53a79ad (patch) | |
tree | 1b9df4838f894577a09b9b260151756272efeb53 /flakes/private/monitoring/plugins/notify_by_apprise | |
parent | fa25ffd4583cc362075cd5e1b4130f33306103f0 (diff) | |
download | Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.gz Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.zst Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.zip |
Squash changes containing private information
There were a lot of changes since the previous commit, but a lot of them
contained personnal information about users. All thos changes got
stashed into a single commit (history is kept in a different place) and
private information was moved in a separate private repository
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 | ||