-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathold-migrate
More file actions
executable file
·141 lines (111 loc) · 2.89 KB
/
old-migrate
File metadata and controls
executable file
·141 lines (111 loc) · 2.89 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
bench=memtouch
#ram=128
#ram=256
ram=1024
vcpu=1
# max link speed 118MB/s or 1000Mb/s
speed=125 # migrate speed in MB/s
mode=precopy
# capability
cap=xbzrle
#cap=none
xbzrle=off # on/off
if [ $cap == "xbzrle" ]; then
xbzrle=on
fi
expno=1
# sysbench params
#prefix=1024_RO_${expno}
# memtouch params
dirtyrate=100 # MB/s
#prefix=s${speed}_r${ram}_d${dirtyrate}_n${expno}
prefix=${expno}
loghome=log
logdir=$loghome/${bench}/${mode}/${cap}/r${ram}/v${vcpu}/s${speed}/d${dirtyrate}
logfile=$logdir/${prefix}.log
dstatfile=$logdir/${prefix}.dstat
migfile=$logdir/${prefix}.mig # nc migration results
mkdir -p $logdir
# for cpu utilization
PREV_TOTAL=0
PREV_IDLE=0
function cpusage() {
CPU=(`grep '^cpu ' /proc/stat`) # Get the total CPU statistics.
unset CPU[0] # Discard the "cpu" prefix.
IDLE=${CPU[4]} # Get the idle CPU time.
# Calculate the total CPU time.
TOTAL=0
for VALUE in "${CPU[@]}"; do
let "TOTAL=$TOTAL+$VALUE"
done
# Calculate the CPU usage since we last checked.
let "DIFF_IDLE=$IDLE-$PREV_IDLE"
let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
echo -e "\rCPU: $DIFF_USAGE % \b\b"
# Remember the total and idle CPU times for the next check.
PREV_TOTAL="$TOTAL"
PREV_IDLE="$IDLE"
}
function ncmigrate() {
nc localhost 4446 << EOF
info status
info version
info kvm
migrate_set_capability xbzrle $xbzrle
info migrate_capabilities
migrate_set_speed $speed
migrate tcp:c11node10:4444
info migrate
info status
quit
EOF
echo
}
echo ram = $ram MB
echo migration speed = $speed MB/s
echo benchmark = $bench
echo dirty rate = $dirtyrate MB/s
echo xbzrle = $xbzrle
echo
#echo sb_${prefix}.log
echo $logfile
echo
dest=c11node10
telnetport=4446
echo "$dest (${ram}MB) listening ..."
ssh $dest /root/qemu/listen-daemon $ram
#ssh $dest /root/qemu/listen-postcopy-daemon $ram
#sleep 3
./runvm-daemon $ram
#./runvm-daemon $ram
echo sleeping 20 seconds ...
sleep 20
echo starting dstat ...
#ssh localhost -p 5555 "dstat -cmdngy > dstat/${prefix}.log" &
dstat -cmdngy > $dstatfile &
# run benchmark (memtouch, sysbench, apache, netperf, lmbench, kc) in background
echo starting memtouch $dirtyrate ...
ssh localhost -p 5555 "/root/run-memtouch $dirtyrate" &
#echo starting sysbench ...
#ssh localhost -p 5555 "/root/run > sysbench/${prefix}.log" &
echo sleeping 10 seconds ...
sleep 10
echo
echo starting migration ...
cpusage
#./ncmigrate-postcopy > log/mt_${prefix}.log
#./ncmigrate $speed
#./ncmigrate > log/${bench}_${prefix}.log
ncmigrate > $migfile
cpusage >> $migfile
egrep -a "time|transferred|bytes|pages|mbps|cache|overflow|CPU" $migfile > $logfile
#grep time -a log/sb_${prefix}.log
#grep time -a log/${bench}_${prefix}.log
echo sleeping 10 seconds ...
sleep 10
# shutdown VM at dest
./stopvm $dest $telnetport
# stop dstat
pgrep -fl dstat| awk '{print $1}' | xargs kill -9