aboutsummaryrefslogtreecommitdiff
path: root/modules/private/monitoring/plugins/notify_by_email
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-07-17 11:33:57 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-07-17 11:33:57 +0200
commit3bc32d9ebd9b0900eeef756122ad28f8857f8bfe (patch)
treeff92459e654fde6fe559dfd383d6a76e05a347cf /modules/private/monitoring/plugins/notify_by_email
parente886ea19877fa0d4de32d35939f69e9c18681d59 (diff)
downloadNix-3bc32d9ebd9b0900eeef756122ad28f8857f8bfe.tar.gz
Nix-3bc32d9ebd9b0900eeef756122ad28f8857f8bfe.tar.zst
Nix-3bc32d9ebd9b0900eeef756122ad28f8857f8bfe.zip
Add monitoring modules via naemon
Diffstat (limited to 'modules/private/monitoring/plugins/notify_by_email')
-rwxr-xr-xmodules/private/monitoring/plugins/notify_by_email31
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/private/monitoring/plugins/notify_by_email b/modules/private/monitoring/plugins/notify_by_email
new file mode 100755
index 0000000..ad0dcc7
--- /dev/null
+++ b/modules/private/monitoring/plugins/notify_by_email
@@ -0,0 +1,31 @@
1#!/usr/bin/env bash
2
3# $1 = service/host
4
5# $2 = type (PROBLEM RECOVERY ACKNOWLEDGEMENT FLAPPINGSTART FLAPPINGSTOP FLAPPINGDISABLED DOWNTIMESTART DOWNTIMESTOP DOWNTIMECANCELLED)
6# http://www.naemon.org/documentation/usersguide/macrolist.html#notificationtype
7
8# $3 = host alias
9
10# $4 = date (YYYY-MM-DDTHH:MM:SS)
11
12# $5 = E-mail
13
14NOTIFICATION_TYPE="$2"
15HOST_ALIAS="$3"
16DATE="$4"
17CONTACT="$5"
18
19message=""
20
21if [ "$1" = "host" ]; then
22 message=$(printf "%b" "***** Naemon *****\n\nNotification Type: $NOTIFICATION_TYPE\n\nHost: $HOST_ALIAS\nState: $HOSTSTATE\nInfo: $HOSTOUTPUT\n\nDate/Time: $DATE\n")
23 subject="** $NOTIFICATION_TYPE Host Alert: $HOST_ALIAS is $HOSTSTATE **"
24else
25 message=$(printf "%b" "***** Naemon *****\n\nNotification Type: $NOTIFICATION_TYPE\n\nService: $SERVICEDESC\nHost: $HOST_ALIAS\nState: $SERVICESTATE\n\nDate/Time: $DATE\n\nAdditional Info:\n\n$SERVICEOUTPUT\n")
26 subject="** $NOTIFICATION_TYPE Service Alert: $HOST_ALIAS/$SERVICEDESC is $SERVICESTATE **"
27fi
28
29# sendwait waits for sendmail to finish its job, otherwise it continues in the
30# background and gets killed too early
31echo "$message" | MAILRC=/dev/null mail -r "naemon@immae.eu" -n -Ssendwait -s "$subject" "$CONTACT"