Skip to content

Commit

Permalink
Fix how major and minor identifiers of block devices are read.
Browse files Browse the repository at this point in the history
The current implementation assure that the major and the minor are
coded on one byte. But they are not:

```
brw-rw----  1 root disk    252, 290 Feb 25 11:36 dm-290
```

290 as minor in this example is over 1 byte.

So after wondering why all my devices iops weren't correctly stored,
I found out that several points were added for some disks. For `dm-290`
it was overriding `252:34`, instead of getting udev stats for `252:290`.

The solution is here:
https://sites.uclouvain.be/SystInfo/usr/include/sys/sysmacros.h.html

The implementation is directly taken from this, fixing my bug.
  • Loading branch information
Soulou committed Mar 11, 2019
1 parent 91cd17f commit 92b01ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/inputs/diskio/diskio_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *DiskIO) diskInfo(devName string) (map[string]string, error) {
}

major := stat.Rdev >> 8 & 0xff
minor := stat.Rdev & 0xff
minor := (stat.Rdev & 0xff) | (stat.Rdev>>12)&^0xff
udevDataPath := fmt.Sprintf("%s/b%d:%d", udevPath, major, minor)

di := map[string]string{}
Expand Down

0 comments on commit 92b01ab

Please sign in to comment.