LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-30-2011, 12:31 AM   #1
arp99
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Rep: Reputation: Disabled
iostat to print disk usage speed


Trying to understand grep,sed,awk but maybe its too early for me and also i suspect iostat is not the correct program for exactly what i'm looking for...

The goal is to print only the current read and write speeds of the disk, represented in a numerical value with two separated commands. So for example when writing a file to disk from an external disk, the value reflects the speed of the process.

"iostat -dk sda" prints
Code:
Linux 2.6.38 (Infidel)  07/30/2011      _x86_64_        (4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               6.68        55.88       215.16     594171    2287812
"iostat -dx sda" prints
Code:
Linux 2.6.38 (Infidel)  07/30/2011      _x86_64_        (4 CPU)

Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               3.47   108.04    2.68    6.76   123.98   917.78   110.40     0.91   96.17   3.83   3.62
I found this also but it doesn't help me so far..
Code:
http://collectl.sourceforge.net/DiskStats.html
Finally, if the exact speed measurements are impossible, one total usage percentage will be ok.
Any clues are welcome..

Last edited by arp99; 07-30-2011 at 12:34 AM.
 
Old 07-30-2011, 12:57 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, welcome to LQ!

Can you explain how the iostat output doesn't match your
requirement? Seems to match your requirement exactly to
my eye ...


Cheers,
Tink
 
Old 07-30-2011, 01:37 AM   #3
arp99
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yea, thats what cross my mind when i saw "kB_read/s" and "kB_wrtn/s" values but after test it when the transfer happens, the numbers remain almost the same.

e.x when copying a file from one external drive with 30-35MBps rate, it's not logical to see only a 0.08 increase in "kB_wrtn/s" value.
 
Old 07-30-2011, 02:33 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I think all you need to do is to tack on a '1' at the end
of your iostat invocation, like so:
Code:
iostat -dk sda 1
If you don't want continuous output try
Code:
iostat -dk sda 1 2
One of the things one needs to be aware of w/ the
sysstat package tools is that their first reading
is commonly garbage.




Cheers,
Tink

Last edited by Tinkster; 07-30-2011 at 02:36 AM.
 
Old 07-30-2011, 03:27 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,839

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
Quote:
Originally Posted by Tinkster View Post
One of the things one needs to be aware of w/ the
sysstat package tools is that their first reading
is commonly garbage.
That's a little (lot) harsh Tink - this is SOP.
Several "monitoring" tools warn of this effect. With no "previous" reading to relate to, the first reading uses the count fields since boot (or process start depending on metric). This skews the result somewhat.
 
Old 07-30-2011, 03:53 AM   #6
arp99
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thank you, i didn't know that.

"1" did the trick in console but i want to add the commands in a monitor script that will invoke them with 1 second interval.
So the "1 2" is the right one for me, but i also need help on how to grep the values of "kB_read/s" and "kB_wrtn/s" only from the second measurement.
Regex is unknown territory for me yet.

Code:
iostat -dk sda 1 2
prints...
Code:
Linux 2.6.38 (Infidel)  07/30/2011      _x86_64_        (4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               9.31        37.34       449.05     901687   10843324

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda              81.00         0.00     41472.00          0      41472
 
Old 07-30-2011, 05:40 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by syg00 View Post
That's a little (lot) harsh Tink - this is SOP.
Several "monitoring" tools warn of this effect. With no "previous" reading to relate to, the first reading uses the count fields since boot (or process start depending on metric). This skews the result somewhat.
Well ... in situations like using iostat w/o further parameters
the first row of results is always the same, which must be
pretty meaningless for anyone; to me that makes it brain dead,
and I'll stick w/ my view =o}
If it won't add any actual information why don't they suppress
the first row, and print the 2nd (meaningful) one?


Cheers,
Tink

Last edited by Tinkster; 07-30-2011 at 05:42 PM.
 
Old 07-30-2011, 05:44 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by arp99 View Post
Thank you, i didn't know that.

"1" did the trick in console but i want to add the commands in a monitor script that will invoke them with 1 second interval.
So the "1 2" is the right one for me, but i also need help on how to grep the values of "kB_read/s" and "kB_wrtn/s" only from the second measurement.
Regex is unknown territory for me yet.

Code:
iostat -dk sda 1 2
prints...
Code:
Linux 2.6.38 (Infidel)  07/30/2011      _x86_64_        (4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               9.31        37.34       449.05     901687   10843324

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda              81.00         0.00     41472.00          0      41472
Assuming your output looks like mine:
Code:
iostat -dk /dev/sda 1 2 | awk 'NR==7{print $3"\t"$4}'
23424.00        0.00
This isn't really a regex thing, just based on position; 7th row,
3rd and 4th field give read & write of the 2 set of actual info.


Cheers,
Tink
 
Old 08-01-2011, 11:12 PM   #9
arp99
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
It works and as far as i can tell, iostat gives u pretty reliable measurements!

Thank you again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disk Usage Analyzer reports too much disk space? ler0nldb2 Linux - Newbie 1 09-12-2009 11:27 AM
Disk usage ak.lokesh Linux - Newbie 4 02-20-2009 05:11 PM
iostat is not working ?? only shows cpu, no disk stats ? BigCohunes Linux - Newbie 2 02-17-2009 08:35 AM
iostat help.no disk stats droberts Linux - Newbie 0 11-09-2005 04:36 PM
101% disk usage on an empty disk tsiuser Linux - Software 3 01-28-2004 07:24 PM


All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration