]>
Commit | Line | Data |
---|---|---|
b5305b5c IB |
1 | #!/bin/bash |
2 | ||
3 | STATE_OK=0 | |
4 | STATE_WARNING=1 | |
5 | STATE_CRITICAL=2 | |
6 | STATE_UNKNOWN=3 | |
7 | ||
8 | base_path=$1 | |
9 | hours=$2 | |
10 | as_user=$3 | |
11 | ||
12 | if [ -z "$as_user" ]; then | |
13 | last_date=$(find $base_path -mindepth 1 -maxdepth 1 -printf "%T@\n" 2>/dev/null | sort | tail -n 1) | |
14 | else | |
15 | last_date=$(sudo -u "$as_user" find $base_path -mindepth 1 -maxdepth 1 -printf "%T@\n" 2>/dev/null | sort | tail -n 1) | |
16 | fi | |
17 | ||
18 | if [ -z "$last_date" ]; then | |
19 | echo "UNKNOWN: Could not read folder" | |
20 | exit $STATE_UNKNOWN | |
21 | else | |
22 | LC_ALL=C last_date=$(printf "%.*f" 0 $last_date) | |
23 | min_date=$(date -d "$hours hours ago" "+%s") | |
24 | if [ "$min_date" -lt "$last_date" ]; then | |
96f8d0f0 | 25 | echo "OK: Last file $(date -d @$last_date)" |
b5305b5c IB |
26 | exit $STATE_OK |
27 | else | |
96f8d0f0 | 28 | echo "CRITICAL: Last file $(date -d @$last_date)" |
b5305b5c IB |
29 | exit $STATE_CRITICAL |
30 | fi | |
31 | fi |