From 54b9b79023ae43e8697856fee9661bd94ae844e0 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 15 Mar 2019 16:30:20 +0100 Subject: [PATCH] Improve debug mode about master SQL request --- check_pg_streaming_replication | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/check_pg_streaming_replication b/check_pg_streaming_replication index 3023d37..ae746a3 100755 --- a/check_pg_streaming_replication +++ b/check_pg_streaming_replication @@ -120,6 +120,12 @@ function psql_get () { echo "$sql"|su - $PG_USER -c "$PSQL_BIN -d "$PG_DB" -w -t -P format=unaligned" } +function psql_master_get () { + sql="$1" + debug "Exec 'echo \"$sql\"|su - $PG_USER -c \"$PSQL_BIN -U $M_USER -h $M_HOST -w -p $M_PORT -d $PG_DB -t -P format=unaligned\"" + echo "$sql"|su - $PG_USER -c "$PSQL_BIN -U $M_USER -h $M_HOST -w -p $M_PORT -d $PG_DB -t -P format=unaligned" +} + function debug() { if [ $DEBUG -eq 1 ] then @@ -211,7 +217,7 @@ then fi # Get current xlog file from master - M_CUR_XLOG="$( echo 'SELECT pg_current_xlog_location()'|su - $PG_USER -c "$PSQL_BIN -U $M_USER -h $M_HOST -p $M_PORT -d $PG_DB -t -P format=unaligned" )" + M_CUR_XLOG="$( psql_master_get 'SELECT pg_current_xlog_location()' )" if [ ! -n "$M_CUR_XLOG" ] then echo "UNKNOWN : Can't retreive current xlog from master server"