diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 01:35:06 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 02:11:48 +0200 |
commit | 1a64deeb894dc95e2645a75771732c6cc53a79ad (patch) | |
tree | 1b9df4838f894577a09b9b260151756272efeb53 /modules/private/monitoring/plugins/check_last_file_date | |
parent | fa25ffd4583cc362075cd5e1b4130f33306103f0 (diff) | |
download | Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.gz Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.zst Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.zip |
Squash changes containing private information
There were a lot of changes since the previous commit, but a lot of them
contained personnal information about users. All thos changes got
stashed into a single commit (history is kept in a different place) and
private information was moved in a separate private repository
Diffstat (limited to 'modules/private/monitoring/plugins/check_last_file_date')
-rwxr-xr-x | modules/private/monitoring/plugins/check_last_file_date | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/modules/private/monitoring/plugins/check_last_file_date b/modules/private/monitoring/plugins/check_last_file_date deleted file mode 100755 index f51a258..0000000 --- a/modules/private/monitoring/plugins/check_last_file_date +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
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 | |||
11 | last_date=$(find $base_path -mindepth 1 -maxdepth 1 -printf "%T@\n" 2>/dev/null | sort | tail -n 1) | ||
12 | |||
13 | if [ -z "$last_date" ]; then | ||
14 | echo "UNKNOWN: Could not read folder" | ||
15 | exit $STATE_UNKNOWN | ||
16 | else | ||
17 | LC_ALL=C last_date=$(printf "%.*f" 0 $last_date) | ||
18 | LC_ALL=C age=$(( $(date "+%s") - $last_date)) | ||
19 | max_age=$(( $hours * 60 * 60 )) | ||
20 | min_date=$(date -d "$hours hours ago" "+%s") | ||
21 | if [ "$min_date" -lt "$last_date" ]; then | ||
22 | echo "OK: Last file $(date -d @$last_date) | age=${age}s;;$max_age;;" | ||
23 | exit $STATE_OK | ||
24 | else | ||
25 | echo "CRITICAL: Last file $(date -d @$last_date) | age=${age}s;;$max_age;;" | ||
26 | exit $STATE_CRITICAL | ||
27 | fi | ||
28 | fi | ||