]> git.proxmox.com Git - ceph.git/blame - ceph/src/mstop.sh
d/control: depend on python3-yaml for ceph-mgr
[ceph.git] / ceph / src / mstop.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2
3set -e
4
5script_root=`dirname $0`
6
9f95a23c
TL
7[ -z "$BUILD_DIR" ] && BUILD_DIR=build
8
7c673cae
FG
9if [ -e CMakeCache.txt ]; then
10 script_root=$PWD
9f95a23c
TL
11elif [ -e $script_root/../${BUILD_DIR}/CMakeCache.txt ]; then
12 script_root=`(cd $script_root/../${BUILD_DIR}; pwd)`
7c673cae
FG
13fi
14
15[ "$#" -lt 1 ] && echo "usage: $0 <name> [entity [id]]" && exit 1
16
17name=$1
18entity=$2
19id=$3
20
21run_root=$script_root/run/$name
22pidpath=$run_root/out
23
24if [ "$entity" == "" ]; then
25 pfiles=`ls $pidpath/*.pid` || true
26elif [ "$id" == "" ]; then
27 pfiles=`ls $pidpath/$entity.*.pid` || true
28else
29 pfiles=`ls $pidpath/$entity.$id.pid` || true
30fi
31
11fdf7f2
TL
32MAX_RETRIES=20
33
7c673cae
FG
34for pidfile in $pfiles; do
35 pid=`cat $pidfile`
36 fname=`echo $pidfile | sed 's/.*\///g'`
7c673cae
FG
37 [ "$pid" == "" ] && exit
38 [ $pid -eq 0 ] && exit
39 echo pid=$pid
40 extra_check=""
41 entity=`echo $fname | sed 's/\..*//g'`
11fdf7f2 42 name=`echo $fname | sed 's/\.pid$//g'`
7c673cae 43 [ "$entity" == "radosgw" ] && extra_check="-e lt-radosgw"
11fdf7f2
TL
44 echo entity=$entity pid=$pid name=$name
45 counter=0
46 signal=""
7c673cae 47 while ps -p $pid -o args= | grep -q -e $entity $extracheck ; do
11fdf7f2
TL
48 if [[ "$counter" -gt MAX_RETRIES ]]; then
49 signal="-9"
50 fi
7c673cae 51 cmd="kill $signal $pid"
11fdf7f2 52 printf "$cmd...\n"
7c673cae
FG
53 $cmd
54 sleep 1
11fdf7f2 55 counter=$((counter+1))
7c673cae
FG
56 continue
57 done
58done
59