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_postgres_database_count | |
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_postgres_database_count')
-rwxr-xr-x | modules/private/monitoring/plugins/check_postgres_database_count | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/modules/private/monitoring/plugins/check_postgres_database_count b/modules/private/monitoring/plugins/check_postgres_database_count deleted file mode 100755 index 43bdd8c..0000000 --- a/modules/private/monitoring/plugins/check_postgres_database_count +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | STATE_OK=0 | ||
4 | STATE_WARNING=1 | ||
5 | STATE_CRITICAL=2 | ||
6 | STATE_UNKNOWN=3 | ||
7 | |||
8 | host=$1 | ||
9 | port=$2 | ||
10 | min=$3 | ||
11 | |||
12 | count=$(psql -h $host -p $port -A -q -c '\t' -c 'select count(datname) from pg_catalog.pg_database' postgres 2>&1) | ||
13 | exit_code=$? | ||
14 | |||
15 | if [[ $exit_code -ne 0 ]]; then | ||
16 | echo "UNKNOWN - Impossible to run psql command: $count" | ||
17 | exit $STATE_UNKNOWN | ||
18 | elif [[ -z "$count" ]]; then | ||
19 | echo "UNKNOWN - No database found" | ||
20 | exit $STATE_UNKNOWN | ||
21 | else | ||
22 | output="Database count is $count" | ||
23 | LC_ALL=C count=$(printf "%.*f" 0 $count) | ||
24 | |||
25 | if [[ $count -gt $min ]]; then | ||
26 | echo "OK - $output | count=${count};$min;$min;0;" | ||
27 | exit $STATE_OK | ||
28 | else | ||
29 | echo "CRITICAL - $output | count=${count};$min;$min;0;" | ||
30 | exit $STATE_CRITICAL | ||
31 | fi | ||
32 | fi | ||