Tuesday, January 9, 2018

linux - disk bytes/s read and write

I'm trying to figure out how to count read and written bytes per second.
At the moment what I'm doing is I read the data from /proc/diskstats which looks like this:




202 0 xvda 80702313 1132334 2823807338 426518304 89838477 177437957 2140229136 1696949080 0 142957364 2123455348



I read the 6th (sectors/s read) and 10th (sectors/s written) fields and multiply them by 512 ( I figured that's the right value by checking the output from fdisk which is saying sectors of 1 * 512 = 512 bytes) which should give me the number of bytes. I take 2 samples and substract the first one from the latter one and then divide the resulting values by the number of seconds in between the samples.
It doesn't seem to give the correct results though. Anyone idea on how this should actually be done ?
I'm looking for something similar to what sar -b outputs



Thanks

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...