-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplot-vmstat.sh
executable file
·66 lines (56 loc) · 1.95 KB
/
plot-vmstat.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
#!/bin/bash
plot() {
suffix=$1
gnuplot <<EOF
set xlabel "time (s)"
set size 1
set terminal pngcairo size ${width:-1280}, 800
set terminal pngcairo size ${width:-1000}, 600
set terminal pngcairo size ${width:-1280}, ${height:-800}
set output "vmstat-written$suffix.png"
set ylabel "size (MB)"
set grid
plot "vmstat$suffix" using 1:(\$3*4/1024) with points pt 5 title "dirtied", \
"vmstat$suffix" using 1:(\$4*4/1024) with points pt 7 title "written"
set output "vmstat-dirty$suffix.png"
set ylabel "size (MB)"
unset grid
plot "vmstat$suffix" using 1:(\$5*4/1024) with points pt 5 title "dirty", \
"vmstat$suffix" using 1:(\$6*4/1024) with points pt 6 title "writeback", \
"vmstat$suffix" using 1:(\$7*4/1024) with points pt 7 title "unstable", \
"vmstat$suffix" using 1:(\$8*4/1024) with points pt 4 title "dirty thresh", \
"vmstat$suffix" using 1:(\$9*4/1024) with points pt 3 title "background thresh"
set output "vmstat-reclaimable$suffix.png"
set ylabel "size (MB)"
set grid
plot "vmstat$suffix" using 1:(\$11*4/1024) with points pt 6 lc rgbcolor "green" title "free", \
"vmstat$suffix" using 1:(\$12*4/1024) with points pt 5 lc rgbcolor "red" title "anon", \
"vmstat$suffix" using 1:(\$13*4/1024) with points pt 7 lc rgbcolor "blue" title "file", \
"vmstat$suffix" using 1:(\$14*4/1024) with points pt 4 lc rgbcolor "magenta" title "slab"
# set output "vmstat-unstable$suffix.png"
# set ylabel "size (MB)"
# plot "vmstat$suffix" using 1:(\$6*4/1024) with points pt 6 title "writeback", \
# "vmstat$suffix" using 1:(\$7*4/1024) with points pt 7 title "unstable"
EOF
}
for dir
do
cd $dir
plot
lines=$(wc -l vmstat | cut -f1 -d' ')
if [[ $lines -ge 300 ]]; then
tail -n 100 vmstat > vmstat-100
plot -100
fi
# if [[ $lines -ge 300 ]]; then
# width=6400
# plot +
# fi
# if [[ $lines -ge 1000 ]]; then
# tail -n 300 vmstat > vmstat-300
# head -n 500 vmstat > vmstat-500
# plot -300
# plot -500
# fi
cd ..
done