-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdse_process_slow
More file actions
executable file
·69 lines (56 loc) · 2 KB
/
dse_process_slow
File metadata and controls
executable file
·69 lines (56 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env sudo bash
# dse_process_slow
#
# Pause a list of processes and restart when user presses return
#
# Slowing DSE process is slowed by hitting the DSE process with timed alternating signals SiGSTOP and SIGCONT.
# The process is aligned to modulo 60 minutes.
# Determine the DSE pid periodically in case it is restarted.
# For general slow node testing a good starting point is
# seconds_to_sigstop=0.90
# seconds_to_sigcont=0.10
#
# If testing Speculative Retry and Speculative Execution operations,
# use a 1 second slow and 1 second fast pattern to better see the results in monitoring graphs.
# seconds_to_sigstop=1
# seconds_to_sigcont=1
#
# Rich Rein 2019.03.20
#
trace_slow_fullspeed=true
trace_stop_start=false
minutes_to_slow=5
seconds_to_sigstop=0.90
seconds_to_sigcont=0.10
was_stopped=88
while [ 1 ]; do
# The pids for a command may change. Reaquire the list of pids every 5 seconds.
slowPids=$(ps aux | grep com.datastax.bdp | grep -v grep | awk '{print $2}')
# Make sure DSE continues at full speed if the scipt is cancelled.
trap 'kill -SIGCONT $slowPids 2>/dev/null' EXIT
if [ x"$slowPids" = x ]; then echo DSE not running; exit 0; fi
minute=$(date '+%M' | sed -e 's/.*\(.\)/\1/')
minutes=$((minute/$minutes_to_slow))
dostop=$(( $minutes % 2 ))
if [ $was_stopped != $dostop ]; then
was_stopped=$dostop
if [ $dostop == 0 ]; then
if [ $trace_slow_fullspeed == true ]; then echo "$(date)" - Start slowing DSE ; fi
else
if [ $trace_slow_fullspeed == true ]; then echo "$(date)" - Start full speed DSE ; fi
fi
fi
for i in {1..10}; do
# SIGSTOP and SIGCONT the processes to reduce CPU used 2>/dev/null
if [ $dostop == 0 ]; then
kill -SIGSTOP $slowPids 2>/dev/null;
if [ $trace_stop_start == true ]; then echo Stopping DSE at $(date) ; fi
fi
sleep $seconds_to_sigstop;
kill -SIGCONT $slowPids 2>/dev/null;
if [ $dostop == 0 ]; then
if [ $trace_stop_start == true ]; then echo Continuing DSE at $(date) ; fi
fi
sleep $seconds_to_sigcont;
done
done