@@ -857,32 +857,31 @@ GET_PG_PID_ACTIVE () {
857857 PORT=$1 ; shift
858858 HOST=$1
859859 PG_LOCK_FILE=" /tmp/.s.PGSQL.${PORT} .lock"
860- PG_LOCK_NETSTAT =" "
860+ PG_LOCK_SS =" "
861861 if [ x" " == x" $HOST " ]; then
862- # See if we have a netstat entry for this local host
862+ # See if we have a ss entry for this local host
863863 PORT_ARRAY=(` $SS -an 2> /dev/null | $AWK ' {for (i =1; i<=NF ; i++) if ($i==".s.PGSQL.${PORT}") print $i}' | $AWK -F" ." ' {print $NF}' | $SORT -u` )
864864 for P_CHK in ${PORT_ARRAY[@]}
865865 do
866- if [ $P_CHK -eq $PORT ]; then PG_LOCK_NETSTAT =$PORT ; fi
866+ if [ $P_CHK -eq $PORT ]; then PG_LOCK_SS =$PORT ; fi
867867 done
868- # PG_LOCK_NETSTAT=`$NETSTAT -an 2>/dev/null |$GREP ".s.PGSQL.${PORT}"|$AWK '{print $NF}'|$HEAD -1`
869868 # See if we have a lock file in /tmp
870869 if [ -f ${PG_LOCK_FILE} ]; then
871870 PG_LOCK_TMP=1
872871 else
873872 PG_LOCK_TMP=0
874873 fi
875- if [ x" " == x" $PG_LOCK_NETSTAT " ] && [ $PG_LOCK_TMP -eq 0 ]; then
874+ if [ x" " == x" $PG_LOCK_SS " ] && [ $PG_LOCK_TMP -eq 0 ]; then
876875 PID=0
877876 LOG_MSG " [INFO]:-No socket connection or lock file in /tmp found for port=${PORT} "
878877 else
879878 # Now check the failure combinations
880- if [ $PG_LOCK_TMP -eq 0 ] && [ x" " != x" $PG_LOCK_NETSTAT " ]; then
879+ if [ $PG_LOCK_TMP -eq 0 ] && [ x" " != x" $PG_LOCK_SS " ]; then
881880 # Have a process but no lock file
882881 LOG_MSG " [WARN]:-No lock file $PG_LOCK_FILE but process running on port $PORT " 1
883882 PID=1
884883 fi
885- if [ $PG_LOCK_TMP -eq 1 ] && [ x" " == x" $PG_LOCK_NETSTAT " ]; then
884+ if [ $PG_LOCK_TMP -eq 1 ] && [ x" " == x" $PG_LOCK_SS " ]; then
886885 # Have a lock file but no process
887886 if [ -r ${PG_LOCK_FILE} ]; then
888887 PID=` $CAT ${PG_LOCK_FILE} | $HEAD -1| $AWK ' {print $1}' `
@@ -892,8 +891,8 @@ GET_PG_PID_ACTIVE () {
892891 fi
893892 LOG_MSG " [WARN]:-Have lock file $PG_LOCK_FILE but no process running on port $PORT " 1
894893 fi
895- if [ $PG_LOCK_TMP -eq 1 ] && [ x" " != x" $PG_LOCK_NETSTAT " ]; then
896- # Have both a lock file and a netstat process
894+ if [ $PG_LOCK_TMP -eq 1 ] && [ x" " != x" $PG_LOCK_SS " ]; then
895+ # Have both a lock file and a ss process
897896 if [ -r ${PG_LOCK_FILE} ]; then
898897 PID=` $CAT ${PG_LOCK_FILE} | $HEAD -1| $AWK ' {print $1}' `
899898 else
@@ -911,21 +910,20 @@ GET_PG_PID_ACTIVE () {
911910 PORT_ARRAY=($( REMOTE_EXECUTE_AND_GET_OUTPUT $HOST " $SS -an 2>/dev/null |$AWK '{for (i =1; i<=NF ; i++) if (\$ i==\" .s.PGSQL.${PORT} \" ) print \$ i}'|$AWK -F\" .\" '{print \$ NF}'|$SORT -u" ) )
912911 for P_CHK in ${PORT_ARRAY[@]}
913912 do
914- if [ $P_CHK -eq $PORT ]; then PG_LOCK_NETSTAT =$PORT ; fi
913+ if [ $P_CHK -eq $PORT ]; then PG_LOCK_SS =$PORT ; fi
915914 done
916- # PG_LOCK_NETSTAT=`$TRUSTED_SHELL $HOST "$NETSTAT -an 2>/dev/null |$GREP ".s.PGSQL.${PORT}" 2>/dev/null"|$AWK '{print $NF}'|$HEAD -1`
917915 PG_LOCK_TMP=$( REMOTE_EXECUTE_AND_GET_OUTPUT $HOST " ls ${PG_LOCK_FILE} 2>/dev/null|$WC -l" )
918- if [ x" " == x" $PG_LOCK_NETSTAT " ] && [ $PG_LOCK_TMP -eq 0 ]; then
916+ if [ x" " == x" $PG_LOCK_SS " ] && [ $PG_LOCK_TMP -eq 0 ]; then
919917 PID=0
920918 LOG_MSG " [INFO]:-No socket connection or lock file $PG_LOCK_FILE found for port=${PORT} "
921919 else
922920 # Now check the failure combinations
923- if [ $PG_LOCK_TMP -eq 0 ] && [ x" " != x" $PG_LOCK_NETSTAT " ]; then
921+ if [ $PG_LOCK_TMP -eq 0 ] && [ x" " != x" $PG_LOCK_SS " ]; then
924922 # Have a process but no lock file
925923 LOG_MSG " [WARN]:-No lock file $PG_LOCK_FILE but process running on port $PORT on $HOST " 1
926924 PID=1
927925 fi
928- if [ $PG_LOCK_TMP -eq 1 ] && [ x" " == x" $PG_LOCK_NETSTAT " ]; then
926+ if [ $PG_LOCK_TMP -eq 1 ] && [ x" " == x" $PG_LOCK_SS " ]; then
929927 # Have a lock file but no process
930928 CAN_READ=$( REMOTE_EXECUTE_AND_GET_OUTPUT $HOST " if [ -r ${PG_LOCK_FILE} ];then echo 1;else echo 0;fi" )
931929
@@ -937,8 +935,8 @@ GET_PG_PID_ACTIVE () {
937935 LOG_MSG " [WARN]:-Have lock file $PG_LOCK_FILE but no process running on port $PORT on $HOST " 1
938936 PID=1
939937 fi
940- if [ $PG_LOCK_TMP -eq 1 ] && [ x" " != x" $PG_LOCK_NETSTAT " ]; then
941- # Have both a lock file and a netstat process
938+ if [ $PG_LOCK_TMP -eq 1 ] && [ x" " != x" $PG_LOCK_SS " ]; then
939+ # Have both a lock file and a ss process
942940 CAN_READ=$( REMOTE_EXECUTE_AND_GET_OUTPUT $HOST " if [ -r ${PG_LOCK_FILE} ];then echo 1;else echo 0;fi" )
943941 if [ $CAN_READ -eq 1 ]; then
944942 PID=$( REMOTE_EXECUTE_AND_GET_OUTPUT $HOST " $CAT ${PG_LOCK_FILE} |$HEAD -1 2>/dev/null" | $AWK ' {print $1}' )
0 commit comments