Platinum Partner

Zcav Capture

// allows you to run zcav (zoned angular constant velocity) utility included with bonnie++ and automatically plot the results with gnuplot.  this one is a real time saver for me. 


#!/bin/bash
#
# ZCAV Capture  btodd3
# version
ver=1.3

# plot temp file
pscript=/tmp/plotscript

function make_script () {
echo '# zcav plot script' >> $pscript
echo >> $pscript
echo '# plot format' >> $pscript
#comment terminal line out and uncomment pause line below to send plot to screen
echo set terminal png picsize 1024 768 >> $pscript
echo set key outside below >> $pscript
echo set key box >> $pscript
echo set grid x y2 >> $pscript
echo set xtics >> $pscript
echo set mxtics >> $pscript
echo set ytics >> $pscript
echo set mytics >> $pscript
echo set y2tics nomirror >> $pscript
echo >> $pscript
echo '# labels' >> $pscript
echo set title '"Zoned Constant Angular Velocity (ZCAV) Results\n'${mfg}' '${capacity}' '${interface}'\nModel - '${model}'\nSerial Number - '${serialnum}'"' >> $pscript
echo set xlabel "'Block #'" >> $pscript
echo set ylabel "'K/s'" >> $pscript
echo set y2label "'Read Time'" >> $pscript
echo set label "'Plot Style - "${style}"'" at screen 0.07, screen 0.01 >> $pscript
echo >> $pscript
echo '# plot it' >> $pscript
echo plot "'${zdata}'" using 1:2 "${ptype}" title "'K/s'" axis x1y1 , "'${zdata}'" using 1:3 "${ptype}" title "'Time'" axis x1y2 >> $pscript
echo >> $pscript
#echo pause -1 >> $pscript
echo '# undo what was done' >> $pscript
echo reset >> $pscript
}

function demo_mode () {
mfg=demo
model=demo
capacity=demo
interface=demo
serialnum=demo
device=demo
zdata="/usr/local/bin/zsample.dat"
zplot=/root/Desktop/demo-zcavplot.png
echo "--- zcavcap Demo Mode ---"
read -p "Enter plot style (1-Normal, 2-Bezier, 4-Unique): " demo_plot_style

# plot style
case "$demo_plot_style" in
1)
ptype=""
style="Normal"
;;
2)
ptype="smooth bezier"
style="Bezier"
;;
4)
ptype="smooth unique"
style="Unique"
;;
*)
ptype=""
style="Normal"
;;
esac

read -p "The following data file will be plotted. (/usr/local/bin/zsample.dat)"
make_script
echo "Generating Plot..."
gnuplot> $zplot $pscript
read -p "Plot script was not deleted. Do you want to delete it now? (1-Yes, 2-No): " pdelete

# delete plot script or not
case "$pdelete" in
1)
rm -f $pscript
exit 0
;;
2)
exit 0
;;
esac
}

# demo mode or not?
if [ -n "$1" ] && [ "$1" == "--demo" ] ; then
	demo=1
else
	demo=0
fi

if [ $demo -ne 0 ]; then
    demo_mode
fi

function replot () {
echo "--- zcavcap Replot ---"
read -p "Enter the unit's Manufacturer: " mfg
read -p "Enter the unit's model: " model
read -p "Enter the unit's capacity (i.e. 80GB): " capacity
read -p "Enter the unit's interface type (i.e. SAS, SATA): " interface
read -p "Enter the unit's serial number: " serialnum
read -p "Enter the data file to plot (i.e. /root/Dekstop/sample.dat): " zdata
read -p "Enter plot style (1-Normal, 2-Bezier, 3-Csplines, 4-Unique, 5-Frequency): " replot_style
zplot=/root/Desktop/"${serialnum}-zcavplot.png"

# replot style
case "$replot_style" in
1)
ptype=""
style="Normal"
;;
2)
ptype="smooth bezier"
style="Bezier"
;;
3)
ptype="smooth csplines"
style="Csplines"
;;
4)
ptype="smooth unique"
style="Unique"
;;
5)
ptype="smooth frequency"
style="Frequency"
;;
*)
ptype=""
style="Normal"
;;
esac

read -p "The following data file will be plotted. $zdata"
make_script
echo "Generating Plot..."
gnuplot> $zplot $pscript
read -p "Plot script was not deleted. Do you want to delete it now? (1-Yes, 2-No): " pdelete

# delete plot script or not
case "$pdelete" in
1)
rm -f $pscript
exit 0
;;
2)
exit 0
;;
esac
}

# replot or not?
if [ -n "$1" ] && [ "$1" == "--replot" ] ; then
	rplt=1
else
	rplt=0
fi

if [ $rplt -ne 0 ]; then
    replot
fi

# trap CTRL-C to clean up temp files
trap "rm -f $pscript ; exit 0" 2

# start
echo
echo "ZCAV Capture v$ver"

# uniques
read -p "Enter the unit's Manufacturer: " mfg
read -p "Enter the unit's model: " model
read -p "Enter the unit's capacity (i.e. 80GB): " capacity
read -p "Enter the unit's interface type (i.e. SAS, SATA): " interface
read -p "Enter the unit's serial number: " serialnum
read -p "Enter the unit's device name (i.e. /dev/hdc): " device
read -p "Enter plot style (1-Normal, 2-Bezier, 3-Csplines, 4-Unique, 5-Frequency): " plot_style
read -p "Enter mode (1-Read, 2-Write): " mode

# setup
zplot=/root/Desktop/"${serialnum}-zcavplot.png"
zdata=/root/Desktop/"${serialnum}.dat"

# plot style
case "$plot_style" in
1)
ptype=""
style="Normal"
;;
2)
ptype="smooth bezier"
style="Bezier"
;;
3)
ptype="smooth csplines"
style="Csplines"
;;
4)
ptype="smooth unique"
style="Unique"
;;
5)
ptype="smooth frequency"
style="Frequency"
;;
*)
ptype=""
style="Normal"
;;
esac

# mode
case "$mode" in
1) md=""
modeid="Read mode"
;;
2) md="-w"
modeid="Write mode"
;;
*) md=""
modeid="Read mode"
;;
esac

# begin capture
echo "Running ZCAV in $modeid - this could take a while depending on disk size and interface..."
zcav $md $device >> $zdata
make_script
echo "Generating Plot..."
gnuplot> $zplot $pscript
rm -f $pscript
sleep 1
echo "Done."
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}