Hi mouse,
in the past I wrote this little shell + awk script:
This samples all the disk activity each 60 seconds by the number of sampling you desire.
At the end gives you a report sorted by the key you prefer (
Read, Write, Total)
You can insert it in crontab and run it when you want
To sample an hour
NCAMP=10;fld=3
if [ $# != 0 ];then
echo $1|grep -Ev "[0-9]" > /dev/null
if [ $? = 1 ];then
if [ `expr $1 \> 100` = 0 ];then NCAMP=$1; fi
fi
fi
case X$2 in
XR|Xr) fld=1;;
XW|Xw) fld=2;;
XT|Xt) fld=3;;
X) fld=3;;
*) echo "disk_io: usage = disk_io Num_of_sampling Sort_Key"
echo " where:"
echo " Num_of_Sampling = Num. of sampling of 60 sec."
echo " Sort_Key = R(ead), W(rite), T(otal)\n"
exit;;
esac
echo "\nDisk\tK/read\tK/write\tK/TOT\tMax \tAvg sampling on"`expr $NCAMP \* 60`" sec."
echo "-----------------------------------------"
iostat -d 60 $NCAMP|awk -vfld=$fld 'BEGIN { OFS="\t";maxhd=0;swx=0;frun=0;ncamp=0
for (i=1; i <=12;i++ ) { hd[i,1]=""; hd[i,2]=0 ; hd[i,3]=0; hd[i,4]=0; hd[i,5]=0 }}
{ if ( $0 ~ /available/ ) { swx=1 }
if ( $0 ~ /hdisk/ ) {
i=substr($1,6) + 1
if ( i > maxhd ) { maxhd = i }
if ( hd[i,1] != "" ) { frun=1 }
if ( frun == 0 ) {
hd[i,1] = $1
if ( swx == 1 ) { Compute() }}
else
{ Compute() }}}
END {
ncamp=ncamp/maxhd
for (i=1; i <=maxhd;i++ ) {
avx=hd[i,4]/ncamp
print hd[i,1],hd[i,2],hd[i,3],hd[i,4],hd[i,5],avx|"sort -nr +"fld }}
function Compute () {
ncamp=ncamp+1
hd[i,2]=hd[i,2]+$5
hd[i,3]=hd[i,3]+$6
peak= $5 + $6
hd[i,4]=hd[i,4]+peak
if ( peak > hd[i,5] ) { hd[i,5] = peak}} '
#-----------------------------------------------
This samples all the disk activity each 60 seconds by the number of sampling you desire.
At the end gives you a report sorted by the key you prefer (
Read, Write, Total)
You can insert it in crontab and run it when you want
To sample an hour you can run it in this way:
script_name 60 R > result_file
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.