-
Notifications
You must be signed in to change notification settings - Fork 0
/
suite_submit_jobs.sh
executable file
·107 lines (84 loc) · 2.45 KB
/
suite_submit_jobs.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# Configure conf.sh first:
#
# Prerequisites:
# - docker-compose, gnuplot, jq (https://stedolan.github.io/jq/download/), bc, imagemagick
# - performance-monitor
# performance-monitor must be configured ($PERF_DIR/src/conf) to
# reach the docker daemon and to watch the "nodered" container.
# - images generated by performance-monitor are under $PERF_DIR/img
# - DATA_ROOT_DIR exists
# - take_results assumes that `ssh $PI_HOST` succeeds
# (modify ~/.ssh/config if needed)
# - there are no files in /tmp/offload in the gateway
set -u
set -e
source conf.sh
if [ $# -lt 2 ]; then
echo "Usage: $0 [-m <metric> <value>] <paralleljobs> <totaljobs> [<suffix>]"
echo " Send totaljobs to nodered with a maximum of paralleljobs to be processed in parallel"
echo " If -m is supplied, jobs are sent while metric (e.g. 'temp') is below value "
echo "Usage: $0 <period> <totaljobs> <threshold-key> <threshold-value> [<suffix>]"
echo " Send totaljobs to nodered each period seconds, offloading when threshold-key is above treshold-value"
echo " threshold-key is one of {cpu, mem, temp, maxlocal}"
echo " suffix defaults to 1"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ $1 = "-m" ]; then
MEASURE=$2
MEASURE_VALUE=$3
shift 3
WAIT="wait-$MEASURE-$MEASURE_VALUE-"
fi
TOTAL=$2
if [ $# -le 3 ]; then
MODE="jobsn"
PARALLEL=$1
SUFFIX=${3:-1}
DATA_DIR="$DATA_ROOT_DIR"/$PARALLEL-$TOTAL-${WAIT:-}$SUFFIX
else
MODE="jobst"
PERIOD=$1
KEY=$3
VALUE=$4
SUFFIX=${5:-1}
DATA_DIR="$DATA_ROOT_DIR"/$PERIOD-$TOTAL-$KEY-$VALUE-$SUFFIX
fi
if [ -d "$DATA_DIR" ]; then
echo "folder already exists, skipping"
exit 0
fi
set -x
cd "$DIR/$ARCH"
docker-compose down || echo "already down"
docker-compose up -d
docker-compose logs > /tmp/node-red.log 2>&1 &
sleep 10
cd $PERF_DIR
node src/index.js &>/tmp/performance-monitor.log &
PERF_PID=$!
echo "performance-monitor PID=$PERF_PID"
sleep 5
cd $DIR
if [ "$MODE" == "jobsn" ]; then
./submit_jobsn.sh $PARALLEL $TOTAL ${MEASURE:-} ${MEASURE_VALUE:-}
else
./submit_jobst.sh $PERIOD $TOTAL $KEY $VALUE
fi
sleep 5
kill -SIGINT $PERF_PID
cd "$DIR/$ARCH" && docker-compose down
cd $DIR
./take_results.sh "$DATA_DIR"
set +e # temporal set -e disable
ps $PERF_PID
while [ $? -eq 0 ]; do
sleep 1
ps $PERF_PID
done
set -e
mv $PERF_DIR/img/* "$DATA_DIR"
cd "$DATA_DIR"
"$DIR"/graphs/process.sh monitor.json *total*.json
set +x