blob: 8eabb57455175d6e99493a5fa1aef9755d9ed5a8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/bash
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
base_path=$1
hours=$2
as_user=$3
if [ -z "$as_user" ]; then
last_date=$(find $base_path -mindepth 1 -maxdepth 1 -printf "%T@\n" 2>/dev/null | sort | tail -n 1)
else
last_date=$(sudo -u "$as_user" find $base_path -mindepth 1 -maxdepth 1 -printf "%T@\n" 2>/dev/null | sort | tail -n 1)
fi
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 backup $(date -d @$last_date)"
exit $STATE_OK
else
echo "CRITICAL: Last backup $(date -d @$last_date)"
exit $STATE_CRITICAL
fi
fi
|