diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-12 08:52:20 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-12 08:52:20 +0200 |
commit | b94d29d098d959707d139b514c5071e5d99e4626 (patch) | |
tree | 96b09b188872a5d48385da467ea4a5990aeb90b0 /modules/profile | |
parent | 625907f0177d335c05c05ae66ae49e20287d14b0 (diff) | |
parent | de68b72374231be37df7c171596672a21a218958 (diff) | |
download | Puppet-b94d29d098d959707d139b514c5071e5d99e4626.tar.gz Puppet-b94d29d098d959707d139b514c5071e5d99e4626.tar.zst Puppet-b94d29d098d959707d139b514c5071e5d99e4626.zip |
Merge branch 'dev'
Diffstat (limited to 'modules/profile')
-rw-r--r-- | modules/profile/files/monitoring/check_date | 32 | ||||
-rw-r--r-- | modules/profile/files/monitoring/check_last_file_date | 4 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/commands.pp | 6 |
3 files changed, 39 insertions, 3 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 | |||
3 | STATE_OK=0 | ||
4 | STATE_WARNING=1 | ||
5 | STATE_CRITICAL=2 | ||
6 | STATE_UNKNOWN=3 | ||
7 | |||
8 | run_command="$1" | ||
9 | hours="$2" | ||
10 | as_user="$3" | ||
11 | |||
12 | if [ -z "$as_user" ]; then | ||
13 | last_date=$($run_command 2>/dev/null | sort | tail -n 1) | ||
14 | else | ||
15 | last_date=$(sudo -u "$as_user" $run_command 2>/dev/null | sort | tail -n 1) | ||
16 | fi | ||
17 | |||
18 | if [ -z "$last_date" ]; then | ||
19 | echo "UNKNOWN: Could not read date" | ||
20 | exit $STATE_UNKNOWN | ||
21 | else | ||
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 | ||
32 | fi | ||
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 |
31 | fi | 31 | fi |
diff --git a/modules/profile/manifests/monitoring/commands.pp b/modules/profile/manifests/monitoring/commands.pp index 1c8d0b4..7c5d8ed 100644 --- a/modules/profile/manifests/monitoring/commands.pp +++ b/modules/profile/manifests/monitoring/commands.pp | |||
@@ -12,6 +12,7 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
12 | "check_command", | 12 | "check_command", |
13 | "check_md_raid", | 13 | "check_md_raid", |
14 | "check_postgres_replication", | 14 | "check_postgres_replication", |
15 | "check_date", | ||
15 | "check_last_file_date", | 16 | "check_last_file_date", |
16 | ].each |$file| { | 17 | ].each |$file| { |
17 | file { "$plugins/$file": | 18 | file { "$plugins/$file": |
@@ -57,7 +58,10 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
57 | require => File["$plugins/check_postgres_replication"]; | 58 | require => File["$plugins/check_postgres_replication"]; |
58 | "check_last_file_date": | 59 | "check_last_file_date": |
59 | command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"', | 60 | command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"', |
60 | require => File["$plugins/check_last_file_date"], | 61 | require => File["$plugins/check_last_file_date"]; |
62 | "check_date": | ||
63 | command_line => '$USER2$/check_date "$ARG1$" "$ARG2$" "$ARG3$"', | ||
64 | require => File["$plugins/check_date"]; | ||
61 | } | 65 | } |
62 | 66 | ||
63 | unless empty($naemon_url) { | 67 | unless empty($naemon_url) { |