diff options
Diffstat (limited to 'modules/private/monitoring/plugins')
-rwxr-xr-x | modules/private/monitoring/plugins/check_maison_bbc | 41 | ||||
-rwxr-xr-x | modules/private/monitoring/plugins/notify_maison_bbc_by_email | 27 |
2 files changed, 0 insertions, 68 deletions
diff --git a/modules/private/monitoring/plugins/check_maison_bbc b/modules/private/monitoring/plugins/check_maison_bbc deleted file mode 100755 index 4a2f799..0000000 --- a/modules/private/monitoring/plugins/check_maison_bbc +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | # kw, kwh, th_hr Bureau, th_hr Chambre_RDC, th_hr Exterieure, th_hr | ||
4 | # Garage, th_hr Mezzanine, th_hr Sejour, th_hr Soufflage | ||
5 | |||
6 | alert=$(date +"%F %H:%M:%S" -d "3 hours ago") | ||
7 | res=$(curl https://maison.bbc.bouya.org/stats.php) | ||
8 | |||
9 | ignored_text="Exterieure Soufflage Mezzanine" | ||
10 | |||
11 | ignored_bat="^(Temp_Nord|Exterieure|Soufflage|Mezzanine)$" | ||
12 | ignored="^(th_hr Exterieure|th_hr Soufflage|th_hr Mezzanine)$" | ||
13 | |||
14 | missing() { | ||
15 | echo "to_entries|[.[]|select(.value < \"$alert\" and .key != \"bat\" $1)|.key + \": \" + .value]|join(\" ; \")" | ||
16 | } | ||
17 | |||
18 | missing_check=$(echo "$res" | jq -r "$(missing "and (.key | test(\"$ignored\") | not)")") | ||
19 | missing_show=$(echo "$res" | jq -r "$(missing "")") | ||
20 | |||
21 | battery() { | ||
22 | echo ".bat|to_entries|[.[]|select((.value[0] < \"$alert\" or (.value[1] | test(\"^0|1|2$\") | not)) $1)|.key + \": \" + .value[0] + \" bat \" + .value[1]]|join(\" ; \")" | ||
23 | } | ||
24 | |||
25 | bat_check=$(echo "$res" | jq -r "$(battery "and (.key | test(\"$ignored_bat\") | not)")") | ||
26 | bat_show=$(echo "$res" | jq -r "$(battery "")") | ||
27 | |||
28 | if [ -n "$missing_check" -o -n "$bat_check" ]; then | ||
29 | text="" | ||
30 | if [ -n "$missing_show" ]; then | ||
31 | text="$text - Dernières dates: $missing_show" | ||
32 | fi | ||
33 | if [ -n "$bat_show" ]; then | ||
34 | text="$text - Batteries: $bat_show" | ||
35 | fi | ||
36 | echo "Zibase CRITICAL$text" | ||
37 | exit 2 | ||
38 | else | ||
39 | echo "Zibase OK - Derniers événements il y a moins de 3h (ignorés : $ignored_text)" | ||
40 | exit 0 | ||
41 | fi | ||
diff --git a/modules/private/monitoring/plugins/notify_maison_bbc_by_email b/modules/private/monitoring/plugins/notify_maison_bbc_by_email deleted file mode 100755 index 84958b8..0000000 --- a/modules/private/monitoring/plugins/notify_maison_bbc_by_email +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 | |||
14 | NOTIFICATION_TYPE="$2" | ||
15 | DATE="$4" | ||
16 | CONTACT="$5" | ||
17 | |||
18 | output=$(echo "$SERVICEOUTPUT" | awk '{gsub(" - ", "\n\n", $0); gsub (" (;|:) ", "\n ", $0); gsub(" dates: ", " dates:\n ", $0); gsub("Batteries: ", "Batteries:\n ", $0); print $0}') | ||
19 | if [ "$NOTIFICATION_TYPE" = "RECOVERY" ]; then | ||
20 | subject="Fin d'alerte Maison BBC Zibase" | ||
21 | message=$(printf "%b" "Alerte terminée le $DATE.\nInformations:\n$output") | ||
22 | else | ||
23 | subject="Alerte Maison BBC Zibase" | ||
24 | message=$(printf "%b" "Alerte lancée le $DATE.\nInformations:\n$output") | ||
25 | fi | ||
26 | |||
27 | echo "$message" | MAILRC=/dev/null mail -r "$ADMINEMAIL" -n -s "$subject" "$CONTACT" | ||