Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disk Activity

Status
Not open for further replies.

mouse123

IS-IT--Management
Dec 16, 2002
82
US
Is there a way to find out disk activity for a 5-hour period continuously and capture it to a file?

thanks
 
I don't know what you mean by "continuously". If you do it every second, for example, I think you might bring the system to its knees.

Take a look at sar (man sar) to see if that would help you. You can set it up to gather stats more frequently than the default.
 
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]=&quot;&quot;; 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] != &quot;&quot; ) { 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|&quot;sort -nr +&quot;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

Hope to be useful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top