Created
June 10, 2014 20:08
-
-
Save itiut/172b960df3d70c518e01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eux | |
cd $(dirname $0) | |
join_sar() { | |
local cpu_out=sar_cpu$1.out | |
local io_out=sar_io$1.out | |
local sar_out=sar$1.out | |
local cpu_out_temp=$cpu_out.temp | |
local io_out_temp=$io_out.temp | |
tail -n +3 $cpu_out | sed 's/ \+/ /g' | cut -d ' ' -f 1,3 > $cpu_out_temp | |
tail -n +3 $io_out | sed 's/ \+/ /g' | cut -d ' ' -f 1,5,6 > $io_out_temp | |
join $cpu_out_temp $io_out_temp | awk '{ print NR-1 " " $2 " " $3*512/1000000.0 " " $4*512/1000000.0 }' | sed '1,1s/^/#/g' | sed '2i 0 0 0 0' > $sar_out | |
rm $cpu_out_temp $io_out_temp | |
} | |
plot() { | |
local sar_out=sar$1.out | |
local eps=sar$1.eps | |
local emf=sar$1.emf | |
# local svg=sar$1.svg | |
# set terminal svg dynamic; | |
# set output '$svg'; | |
# replot; | |
gnuplot <<EOPLT | |
set ytics nomirror; | |
set y2tics; | |
set grid; | |
set xlabel 'Time [sec]'; | |
set ylabel 'CPU Usage [%]' | |
set y2label 'Disk Throughput [MB/s]' | |
set terminal eps; | |
set output '$eps' | |
plot '$sar_out' u 1:2 w l t 'CPU Usage', '$sar_out' u 1:3 w l t 'Disk Read' axes x1y2, '$sar_out' u 1:4 w l t 'Disk Write' axes x1y2; | |
set terminal emf; | |
set output '$emf'; | |
replot; | |
EOPLT | |
} | |
if [ $# -ne 1 ]; then | |
echo "Usage: [$0] directory" | |
exit | |
fi | |
cd $1 | |
for i in $(seq 1 9); do | |
join_sar $i | |
plot $i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment