integ/tools/engtools/hostdata-collectors/scripts/cleanup-engtools.sh
Martin Chen dba551a518 Fix linters error and enable linters zuul gate
Fix below linters errors
E010 The "do" should be on same line as for
E010 The "do" should be on same line as while
E011 Then keyword is not on same line as if or elif keyword
E020 Function declaration not in format ^function name {$

Ignore:
E041 Arithmetic expansion using $[ is deprecated for $((
E042 local declaration hides errors
E043 Arithmetic compound has inconsistent return semantics
E044 Use [[ for non-POSIX comparisions

Story: 2003366
Task: 24423

Change-Id: I8b6b72e702d3e89d1813772d6bf16819e28e818c
Signed-off-by: Martin Chen <haochuan.z.chen@intel.com>
2018-09-07 01:50:28 +08:00

55 lines
1.2 KiB
Bash

#!/bin/bash
# Purpose:
# Some of the engtools scripts are not shutting down gracefully.
# Define common utility functions
TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh
if [ $UID -ne 0 ]; then
ERRLOG "Require sudo/root access."
exit 1
fi
declare -a TOOLS
TOOLS=()
TOOLS+=('collect-engtools.sh')
TOOLS+=('ceph.sh')
TOOLS+=('diskstats.sh')
TOOLS+=('iostat.sh')
TOOLS+=('rabbitmq.sh')
TOOLS+=('ticker.sh')
TOOLS+=('top.sh')
TOOLS+=('memstats.sh')
TOOLS+=('netstats.sh')
TOOLS+=('postgres.sh')
TOOLS+=('vswitch.sh')
TOOLS+=('filestats.sh')
TOOLS+=('live_stream.py')
LOG "Cleanup engtools:"
# Brute force methods (assume trouble with: service collect-engtools.sh stop)
# ( be sure not to clobber /etc/init.d/collect-engtools.sh )
LOG "kill processes brute force"
pids=( $(pidof -x /usr/local/bin/collect-engtools.sh) )
if [ ${#pids[@]} -ne 0 ]; then
LOG "killing: ${pids[@]}"
for pid in ${pids[@]}; do
LOG "kill: [ ${pid} ] "
pkill -KILL -P ${pid}
kill -9 ${pid}
done
pkill -KILL iostat
pkill -KILL top
else
LOG "no pids found"
fi
LOG "remove pidfiles"
for TOOL in "${TOOLS[@]}"; do
rm -f -v /var/run/${TOOL}.pid
done
LOG "done"
exit 0