Skip to content

Comments

Use procfs/blockdevice for diskstats#2072

Closed
luizluca wants to merge 1 commit intoprometheus:masterfrom
luizluca:disk_sys
Closed

Use procfs/blockdevice for diskstats#2072
luizluca wants to merge 1 commit intoprometheus:masterfrom
luizluca:disk_sys

Conversation

@luizluca
Copy link
Contributor

@luizluca luizluca commented Jul 6, 2021

Use procfs/blockdevice for diskstats

diskstats now use procfs/blockdevice instead of manually reading
procfs. A new option collector.diskstats.prefer-sysfs (false by
default) can switch from /proc to /sys metrics. If /sys reading
fails, it will fallback to /proc.

Although reading /sys/block/<dev>/stat is slower, /proc/diskstats
have never garanteed atomicity between lines. Both /proc and /sys
data are equivalent except for partitions as procfs/blockdevice
/sys library does not include partition metrics. For now, if the
user expects to get partition metrics by changing default
ignored-devices, prefer-sysfs cannot be true.

Partition filtering was extended to match mmcblk0p[12].

The diskstats_linux_test.go was not implemented.

Signed-off-by: Luiz Angelo Daros de Luca luizluca@gmail.com

diskstats now use procfs/blockdevice instead of manually reading
procfs. It prefers to use /sys but it will fallback to /proc
if /sys fails. Although reading /sys/block/<dev>/stat is slower,
/proc/diskstats have never garanteed atomicity between lines.
A new option collector.diskstats.prefer-sysfs (true by default)
can be used to skip /sys.

Using /sys, diskstats will ignore partitions. If they are needed,
/proc must be used or procfs/blockdevice must be extended. This
solves issues with ambiguous names like xvda1 that that can both
represent a partition in xvda or a standalone disk (Fixes prometheus#2041).
If collector.diskstats.ignored-devices was changed to include
partitions, collector.diskstats.prefer-sysfs must be set to false.
if collector.diskstats.ignored-devices was untouched, both /proc
and /sys should return the same results.

With /sys as default, collector.diskstats.ignored-devices could
be simplified to match only device names, not partitions. For now,
partition filtering was kept and extended to match mmcblk0p[12].

The diskstats_linux_test.go was not implemented for /sys/block.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant