-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplot-dstat.sh
executable file
·65 lines (45 loc) · 1.35 KB
/
plot-dstat.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
#!/bin/bash
dstat=dstat
for dir
do
# iostat -kx 1
# avg-cpu: %user %nice %system %iowait %steal %idle
# 0.75 0.00 6.36 18.20 0.00 74.69
# 1 2 3 4 5 6
# Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
# sda 0.00 0.00 0.00 136.63 0.00 63065.35 923.13 143.09 1416.26 7.28 99.41
# 1 2 3 4 5 6 7 8 9 10 11 12
plot() {
dstat=$1
start_time=$2
suffix=$3
gnuplot <<EOF
set xlabel "time (s)"
set size 1
set terminal pngcairo size ${width:-1280}, 800
set terminal pngcairo size ${width:-1000}, 600
set grid
set datafile separator ","
set output "$dstat-bw$suffix.png"
set ylabel "throughput (MB/s)"
plot "$dstat" using (\$1 - $start_time):(\$9/1048576) with linespoints pt 5 title "disk write MB/s", \
"$dstat" using (\$1 - $start_time):(\$11/1048576) with linespoints pt 7 title "net send MB/s"
unset grid
EOF
}
cd $dir
test -s $dstat || exit
start_time=$(awk -F',' '{ if ($1 > 0) { print $1; exit } }' $dstat)
plot $dstat $start_time
# lines=$(wc -l iostat-disk | cut -f1 -d' ')
# if [[ $lines -gt 100 ]]; then
# tail -n 50 < iostat-disk > iostat-disk-50
# tail -n 50 < iostat-cpu > iostat-cpu-50
# plot iostat-disk-50 iostat-cpu-50 -50
# fi
# if [[ $lines -ge 100 ]]; then
# width=3200
# plot $trace iostat-disk iostat-cpu +
# fi
cd ..
done