Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate Linux disk bytes read/written based on sector size #180

Merged

Conversation

pdf
Copy link
Contributor

@pdf pdf commented Dec 27, 2015

This is only calculated for raw devices, since determinining the parent
device for partitions would require additional work, and partitions are
excluded from collection by default.

@pdf pdf force-pushed the diskstats_linux_bytes_read_written branch 3 times, most recently from f2473bc to 333afa7 Compare December 27, 2015 03:01
@pdf
Copy link
Contributor Author

pdf commented Dec 27, 2015

It should be possible to make this work for partitions by walking up the sysfs tree if that's desirable, and that would avoid the hacky line size check in Update, would require a whole lotta fixtures though.

@pdf pdf force-pushed the diskstats_linux_bytes_read_written branch from 333afa7 to 099b8be Compare December 27, 2015 03:04
return parseDiskSectorSize(file)
}

func parseDiskSectorSize(r io.Reader) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conntrack module has a function for this already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, can move this out to helpers.go

Logical sector size appears to be fixed at 512B for the foreseeable
future in the kernel, so for now we just hard-code it.
@pdf pdf force-pushed the diskstats_linux_bytes_read_written branch from 099b8be to 09e610a Compare December 27, 2015 11:00
@pdf
Copy link
Contributor Author

pdf commented Dec 27, 2015

Hard-coding the sector size certainly simplifies things, though I wonder if it's worth including this if we're going just going to make this assumption, since it can be fairly easily scaled by query.

@brian-brazil
Copy link
Contributor

I think it's worthwhile. We generally want things to be in bytes, and users not having to worry about the nitty-gritty of kernel internals is good.

brian-brazil added a commit that referenced this pull request Dec 28, 2015
Calculate Linux disk bytes read/written based on sector size
@brian-brazil brian-brazil merged commit a59c71b into prometheus:master Dec 28, 2015
@brian-brazil
Copy link
Contributor

Thanks!

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.

2 participants