Calculate Linux disk bytes read/written based on sector size (512B)

Logical sector size appears to be fixed at 512B for the foreseeable
future in the kernel, so for now we just hard-code it.
This commit is contained in:
Peter Fern 2015-12-27 12:59:02 +11:00
commit 09e610ad37
3 changed files with 150 additions and 70 deletions

View file

@ -37,4 +37,12 @@ func TestDiskStats(t *testing.T) {
if want, got := "68", diskStats["mmcblk0p2"][10]; want != got {
t.Errorf("want diskstats mmcblk0p2 %s, got %s", want, got)
}
if want, got := "513713216512", diskStats["sda"][11]; want != got {
t.Errorf("want diskstats sda read bytes %s, got %s", want, got)
}
if want, got := "258916880384", diskStats["sda"][12]; want != got {
t.Errorf("want diskstats sda write bytes %s, got %s", want, got)
}
}