]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/monitoring/plugins/check_postgres_replication
Squash changes containing private information
[perso/Immae/Config/Nix.git] / modules / private / monitoring / plugins / check_postgres_replication
diff --git a/modules/private/monitoring/plugins/check_postgres_replication b/modules/private/monitoring/plugins/check_postgres_replication
deleted file mode 100755 (executable)
index ff257a3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-STATE_OK=0
-STATE_WARNING=1
-STATE_CRITICAL=2
-STATE_UNKNOWN=3
-
-user=$1
-host=$2
-port=$3
-
-lag=$(psql -h $host -p $port -A -t -c "SELECT COALESCE(EXTRACT(EPOCH FROM replay_lag),0) FROM pg_stat_replication WHERE usename='$user'" 2>/dev/null)
-exit_code=$?
-
-if [[ $exit_code -ne 0 ]]; then
-  echo "UNKNOWN - Impossible to run psql command"
-  exit $STATE_UNKNOWN
-elif [[ -z "$lag" ]]; then
-  echo "UNKNOWN - No replication found for $user"
-  exit $STATE_UNKNOWN
-else
-  output="Replication lag for $user is ${lag}s"
-  LC_ALL=C lag=$(printf "%.*f" 0 $lag)
-
-  if [[ $lag -lt 5 ]]; then
-    echo "OK - $output | time=${lag}s;5;10;0;"
-    exit $STATE_OK
-  elif [[ $lag -lt 10 ]]; then
-    echo "WARNING - $output | time=${lag}s;5;10;0;"
-    exit $STATE_WARNING
-  else
-    echo "CRITICAL - $output | time=${lag}s;5;10;0;"
-    exit $STATE_CRITICAL
-  fi
-fi