diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/mstop.sh | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mstop.sh')
-rwxr-xr-x | src/mstop.sh | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mstop.sh b/src/mstop.sh new file mode 100755 index 00000000..0dfe715e --- /dev/null +++ b/src/mstop.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -e + +script_root=`dirname $0` + +if [ -e CMakeCache.txt ]; then + script_root=$PWD +elif [ -e $script_root/../build/CMakeCache.txt ]; then + script_root=`(cd $script_root/../build; pwd)` +fi + +[ "$#" -lt 1 ] && echo "usage: $0 <name> [entity [id]]" && exit 1 + +name=$1 +entity=$2 +id=$3 + +run_root=$script_root/run/$name +pidpath=$run_root/out + +if [ "$entity" == "" ]; then + pfiles=`ls $pidpath/*.pid` || true +elif [ "$id" == "" ]; then + pfiles=`ls $pidpath/$entity.*.pid` || true +else + pfiles=`ls $pidpath/$entity.$id.pid` || true +fi + +MAX_RETRIES=20 + +for pidfile in $pfiles; do + pid=`cat $pidfile` + fname=`echo $pidfile | sed 's/.*\///g'` + [ "$pid" == "" ] && exit + [ $pid -eq 0 ] && exit + echo pid=$pid + extra_check="" + entity=`echo $fname | sed 's/\..*//g'` + name=`echo $fname | sed 's/\.pid$//g'` + [ "$entity" == "radosgw" ] && extra_check="-e lt-radosgw" + echo entity=$entity pid=$pid name=$name + counter=0 + signal="" + while ps -p $pid -o args= | grep -q -e $entity $extracheck ; do + if [[ "$counter" -gt MAX_RETRIES ]]; then + signal="-9" + fi + cmd="kill $signal $pid" + printf "$cmd...\n" + $cmd + sleep 1 + counter=$((counter+1)) + continue + done +done + |