From f7b4c32f59193c805cac2709af662c65d96d6e34 Mon Sep 17 00:00:00 2001 From: dcd <1151627903@qq.com> Date: Fri, 1 Nov 2024 18:40:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20tlinux4=E7=B3=BB=E7=BB=9F=20proxy?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E8=84=9A=E6=9C=AC=E5=8F=8Agsectl=E9=80=82?= =?UTF-8?q?=E9=85=8D=20(closed=20#2483)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script_tools/agent_tools/agent2/setup_proxy.sh | 4 ++-- script_tools/gsectl/proxy/linux/gsectl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/script_tools/agent_tools/agent2/setup_proxy.sh b/script_tools/agent_tools/agent2/setup_proxy.sh index 8ed7b13c8..2f6bcce68 100755 --- a/script_tools/agent_tools/agent2/setup_proxy.sh +++ b/script_tools/agent_tools/agent2/setup_proxy.sh @@ -224,9 +224,9 @@ get_pid_by_comm_path () { local _pids pids local pid if [[ "${worker}" == "WORKER" ]]; then - read -r -a _pids <<< "$(ps --no-header -C $comm -o '%P|%p|%a' | awk -v proc="${comm}" -F'|' '$1 != 1 && $3 ~ proc' | awk -F'|' '{print $2}' | xargs)" + read -r -a _pids <<< "$(ps --no-header -C $comm -o 'ppid,pid,args' | awk -v proc="${comm}" '$1 != 1 && $3 ~ proc {print $2}' | xargs)" elif [[ "${worker}" == "MASTER" ]]; then - read -r -a _pids <<< "$(ps --no-header -C $comm -o '%P|%p|%a' | awk -v proc="${comm}" -F'|' '$1 == 1 && $3 ~ proc' | awk -F'|' '{print $2}' | xargs)" + read -r -a _pids <<< "$(ps --no-header -C $comm -o 'ppid,pid,args' | awk -v proc="${comm}" '$1 == 1 && $3 ~ proc {print $2}' | xargs)" else read -r -a _pids <<< "$(ps --no-header -C "$comm" -o pid | xargs)" fi diff --git a/script_tools/gsectl/proxy/linux/gsectl b/script_tools/gsectl/proxy/linux/gsectl index 609d851e5..f751e67f1 100755 --- a/script_tools/gsectl/proxy/linux/gsectl +++ b/script_tools/gsectl/proxy/linux/gsectl @@ -309,7 +309,7 @@ get_process_runtime (){ for i in {1..20} do - tmp_gse_master_pid_info=$(ps --no-header -C gse_${module} -o '%P' -o '|%p' -o '|%a' | awk -F'|' '$1 == 1 && $3 ~ /gse_'${module}'/' | awk -F'|' '{print $2}' | xargs) + tmp_gse_master_pid_info=$(ps --no-header -C gse_${module} -o 'ppid,pid,args' | awk '$1 == 1 && $3 ~ /'gse_${module}'/ {print $2}' | xargs) read -r -a tmp_gse_agent_master_pids <<< "$tmp_gse_master_pid_info" for _pid in "${tmp_gse_agent_master_pids[@]}"; do @@ -351,7 +351,7 @@ __status (){ # 最多等待20s来判断是否真正启动成功 for i in {0..20}; do if [ "$action" == "stop" ];then - if [ $(ps --no-header -C gse_${module} -o '%P' -o '|%p' -o '|%a' |egrep "${WORK_HOME}" |wc -l) -eq 0 ];then + if [ $(ps --no-header -C gse_${module} -o 'ppid,pid,args' |egrep "${WORK_HOME}" |wc -l) -eq 0 ];then echo gse_${module} $action $action success break elif [ $i -eq 20 ];then @@ -423,7 +423,7 @@ _status () { # 初筛,考虑到gse组件的父、子进程都是名为gse_${module}的,且它的父进程应该是等于1 # ps的-o参数指定输出字段%P(ppid)、%p(pid)、%a(args) # 所以下面命令是拉出所有进程名为gse_${module},且父进程为1,进程参数包含gse_${module}的进程信息 - gse_master_pid_info=$(ps --no-header -C gse_${module} -o '%P' -o '|%p' -o '|%a' | awk -F'|' '$1 == 1 && $3 ~ /'gse_${module}'/' | awk -F'|' '{print $2}' | xargs) + gse_master_pid_info=$(ps --no-header -C gse_${module} -o 'ppid,pid,args' | awk '$1 == 1 && $3 ~ /'gse_${module}'/ {print $2}' | xargs) read -r -a gse_agent_master_pids <<< "$gse_master_pid_info" if [[ -z "$gse_agent_master_pids" ]]; then