]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/monitoring/plugins/notify_maison_bbc_by_email
Improve history page
[perso/Immae/Config/Nix.git] / modules / private / monitoring / plugins / notify_maison_bbc_by_email
CommitLineData
e820134d
IB
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"
15DATE="$4"
16CONTACT="$5"
17
18output=$(echo "$SERVICEOUTPUT" | awk '{gsub(" - ", "\n\n", $0); gsub (" (;|:) ", "\n ", $0); gsub(" dates: ", " dates:\n ", $0); gsub("Batteries: ", "Batteries:\n ", $0); print $0}')
19if [ "$NOTIFICATION_TYPE" = "RECOVERY" ]; then
20 subject="Fin d'alerte Maison BBC Zibase"
21 message=$(printf "%b" "Alerte terminée le $DATE.\nInformations:\n$output")
22else
23 subject="Alerte Maison BBC Zibase"
24 message=$(printf "%b" "Alerte lancée le $DATE.\nInformations:\n$output")
25fi
26
27echo "$message" | MAILRC=/dev/null mail -r "$ADMINEMAIL" -n -s "$subject" "$CONTACT"