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) Code:
Linux 2.6.38 (Infidel) 07/30/2011 _x86_64_ (4 CPU) Code:
http://collectl.sourceforge.net/DiskStats.html Any clues are welcome.. |
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 |
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. |
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 Code:
iostat -dk sda 1 2 sysstat package tools is that their first reading is commonly garbage. Cheers, Tink |
Quote:
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. |
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 Code:
Linux 2.6.38 (Infidel) 07/30/2011 _x86_64_ (4 CPU) |
Quote:
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 |
Quote:
Code:
iostat -dk /dev/sda 1 2 | awk 'NR==7{print $3"\t"$4}' 3rd and 4th field give read & write of the 2 set of actual info. Cheers, Tink |
It works and as far as i can tell, iostat gives u pretty reliable measurements!
Thank you again |
All times are GMT -5. The time now is 05:11 AM. |