From dd5063850390d5970da325c4b84ddd1d6b854672 Mon Sep 17 00:00:00 2001 From: Jonathon McMurray Date: Wed, 26 Apr 2023 14:20:04 +0100 Subject: [PATCH] Fix port retrieval in torq.sh summary (#554) --- torq.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torq.sh b/torq.sh index b44d6815c..96b921d3c 100755 --- a/torq.sh +++ b/torq.sh @@ -55,7 +55,7 @@ parameter() { findproc() { procno=$(awk '/,'$1',/{print NR}' "$CSVPATH") # get line number for file - pgrep -f "\-stackid ${KDBBASEPORT} \-proctype $(getfield "$procno" proctype) \-procname $1" # get pid of process + pgrep -f "\-stackid ${KDBBASEPORT} \-proctype $(getfield "$procno" proctype) \-procname $1 " # get pid of process } startline() { @@ -132,7 +132,7 @@ summary() { printf "%s | %s | down |" "$(date '+%H:%M:%S')" "$1" # summary table row for down process else pid=$((findproc "$1")|awk 'END{print}') - port=$(echo $(netstat -nlp 2>/dev/null | grep -w "$pid" | awk '{ print $4 }' | awk -F: '{ print $2 }')) # get port process is running on + port=$(echo $(netstat -nlp 2>/dev/null | grep " $pid/" | awk '{ print $4 }' | awk -F: '{ print $2 }')) # get port process is running on printf "%s | %s | up | %s | %s" "$(date '+%H:%M:%S')" "$1" "$pid" "$port" # summary table row for running process fi fi