From 9f2025235d888eb4a7822024a5fad2e288388814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 1 Dec 2019 18:25:16 +0100 Subject: Add monitoring for backup-2 --- .../monitoring/plugins/check_last_file_date | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 modules/private/monitoring/plugins/check_last_file_date (limited to 'modules/private/monitoring/plugins/check_last_file_date') diff --git a/modules/private/monitoring/plugins/check_last_file_date b/modules/private/monitoring/plugins/check_last_file_date new file mode 100755 index 0000000..df45bbc --- /dev/null +++ b/modules/private/monitoring/plugins/check_last_file_date @@ -0,0 +1,26 @@ +#!/bin/bash + +STATE_OK=0 +STATE_WARNING=1 +STATE_CRITICAL=2 +STATE_UNKNOWN=3 + +base_path=$1 +hours=$2 + +last_date=$(find $base_path -mindepth 1 -maxdepth 1 -printf "%T@\n" 2>/dev/null | sort | tail -n 1) + +if [ -z "$last_date" ]; then + echo "UNKNOWN: Could not read folder" + exit $STATE_UNKNOWN +else + LC_ALL=C last_date=$(printf "%.*f" 0 $last_date) + min_date=$(date -d "$hours hours ago" "+%s") + if [ "$min_date" -lt "$last_date" ]; then + echo "OK: Last file $(date -d @$last_date)" + exit $STATE_OK + else + echo "CRITICAL: Last file $(date -d @$last_date)" + exit $STATE_CRITICAL + fi +fi -- cgit v1.2.3