From f883216050a71b167a6060a3b0b44b8e105cc6d6 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 15 Mar 2019 16:29:07 +0100 Subject: [PATCH] Improve master connection informations detection reliability --- check_pg_streaming_replication | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check_pg_streaming_replication b/check_pg_streaming_replication index c314677..3023d37 100755 --- a/check_pg_streaming_replication +++ b/check_pg_streaming_replication @@ -170,7 +170,7 @@ then # Get master connection informations from recovery.conf file - MASTER_CONN_INFOS=$( egrep '^ *primary_conninfo' $RECOVERY_CONF|sed "s/^ *primary_conninfo *= *[\"\']\([^\"\']*\)[\"\'].*$/\1/" ) + MASTER_CONN_INFOS=$( egrep '^ *primary_conninfo' $RECOVERY_CONF|sed "s/^ *primary_conninfo *= *\(.\+\) *$/\1/" ) if [ ! -n "$MASTER_CONN_INFOS" ] then echo "UNKNOWN : Can't retreive master connection informations form recovery.conf file" @@ -178,7 +178,7 @@ then fi debug "Master connection informations : $MASTER_CONN_INFOS" - M_HOST=$( echo "$MASTER_CONN_INFOS"|sed 's/^.*host= *\([^ ]*\) *.*$/\1/' ) + M_HOST=$( echo "$MASTER_CONN_INFOS"| grep 'host=' | sed 's/^.*host= *\([0-9a-zA-Z.-]\+\) *.*$/\1/' ) if [ ! -n "$M_HOST" ] then echo "UNKNOWN : Can't retreive master host from recovery.conf file" @@ -200,7 +200,7 @@ then debug "Master user provided by command-line, use it : $PG_MASTER_USER" M_USER="$PG_MASTER_USER" else - M_USER=$( echo "$MASTER_CONN_INFOS"|sed 's/^.*user= *\([^ ]*\) *.*$/\1/' ) + M_USER=$( echo "$MASTER_CONN_INFOS"| grep 'user=' | sed 's/^.*user= *\([0-9a-zA-Z.-]\+\) *.*$/\1/' ) if [ ! -n "$M_USER" ] then debug "Master user not specified, use default : $PG_USER"