X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=blobdiff_plain;f=modules%2Fprivate%2Fmonitoring%2Fplugins%2Fcheck_postgres_replication;fp=modules%2Fprivate%2Fmonitoring%2Fplugins%2Fcheck_postgres_replication;h=0000000000000000000000000000000000000000;hp=ff257a353e23eddb59aa4e59721b6a695e09fadb;hb=1a64deeb894dc95e2645a75771732c6cc53a79ad;hpb=fa25ffd4583cc362075cd5e1b4130f33306103f0 diff --git a/modules/private/monitoring/plugins/check_postgres_replication b/modules/private/monitoring/plugins/check_postgres_replication deleted file mode 100755 index ff257a3..0000000 --- a/modules/private/monitoring/plugins/check_postgres_replication +++ /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