aboutsummaryrefslogtreecommitdiff
path: root/modules/profile/files
diff options
context:
space:
mode:
Diffstat (limited to 'modules/profile/files')
-rw-r--r--modules/profile/files/monitoring/check_date32
-rw-r--r--modules/profile/files/monitoring/check_last_file_date4
2 files changed, 34 insertions, 2 deletions
diff --git a/modules/profile/files/monitoring/check_date b/modules/profile/files/monitoring/check_date
new file mode 100644
index 0000000..e7ac38a
--- /dev/null
+++ b/modules/profile/files/monitoring/check_date
@@ -0,0 +1,32 @@
1#!/bin/bash
2
3STATE_OK=0
4STATE_WARNING=1
5STATE_CRITICAL=2
6STATE_UNKNOWN=3
7
8run_command="$1"
9hours="$2"
10as_user="$3"
11
12if [ -z "$as_user" ]; then
13 last_date=$($run_command 2>/dev/null | sort | tail -n 1)
14else
15 last_date=$(sudo -u "$as_user" $run_command 2>/dev/null | sort | tail -n 1)
16fi
17
18if [ -z "$last_date" ]; then
19 echo "UNKNOWN: Could not read date"
20 exit $STATE_UNKNOWN
21else
22 last_date=$(date -d "$last_date" "+%s")
23 LC_ALL=C last_date=$(printf "%.*f" 0 $last_date)
24 min_date=$(date -d "$hours hours ago" "+%s")
25 if [ "$min_date" -lt "$last_date" ]; then
26 echo "OK: Last date $(date -d @$last_date)"
27 exit $STATE_OK
28 else
29 echo "CRITICAL: Last date $(date -d @$last_date)"
30 exit $STATE_CRITICAL
31 fi
32fi
diff --git a/modules/profile/files/monitoring/check_last_file_date b/modules/profile/files/monitoring/check_last_file_date
index 8eabb57..d520a84 100644
--- a/modules/profile/files/monitoring/check_last_file_date
+++ b/modules/profile/files/monitoring/check_last_file_date
@@ -22,10 +22,10 @@ else
22 LC_ALL=C last_date=$(printf "%.*f" 0 $last_date) 22 LC_ALL=C last_date=$(printf "%.*f" 0 $last_date)
23 min_date=$(date -d "$hours hours ago" "+%s") 23 min_date=$(date -d "$hours hours ago" "+%s")
24 if [ "$min_date" -lt "$last_date" ]; then 24 if [ "$min_date" -lt "$last_date" ]; then
25 echo "OK: Last backup $(date -d @$last_date)" 25 echo "OK: Last file $(date -d @$last_date)"
26 exit $STATE_OK 26 exit $STATE_OK
27 else 27 else
28 echo "CRITICAL: Last backup $(date -d @$last_date)" 28 echo "CRITICAL: Last file $(date -d @$last_date)"
29 exit $STATE_CRITICAL 29 exit $STATE_CRITICAL
30 fi 30 fi
31fi 31fi