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

Add Linux Networking counters #72

Merged

Conversation

fearful-symmetry
Copy link
Contributor

@fearful-symmetry fearful-symmetry commented Dec 2, 2019

See elastic/beats#12210

Started this before I left for a 4-day weekend so it might be a tad all over, hopefully not.

I fear this is a case of me being a bit too 'clever' since I came up with a way to have one method that populates all of the structs. It would be possible to combine fillStruct and readAndParseNetFile , but then we would need FieldbyName as opposed to Field to get the struct, which means each call would iterate over the struct NumField() times as FieldByName just iterates until it gets a given name. I would still like to find a better way to do this.

Other than that, this is fairly straight forward. The mapping of struct field -> map is because the network counter types are known, but there's basically no documentation on the counters themselves, they're just random kernel fields. I think it would be better to have this library be more neutral, and any editorializing/filtering can be done in metricbeat.

Ah! Still need to update the readme.

@fearful-symmetry fearful-symmetry added the enhancement New feature or request label Dec 2, 2019
@fearful-symmetry fearful-symmetry self-assigned this Dec 2, 2019
@fearful-symmetry fearful-symmetry changed the title Networking counters Add Linux Networking counters Dec 2, 2019
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

LGTM, just added some suggestions on tests, let me know what you think.

providers/linux/procnet.go Show resolved Hide resolved
providers/linux/host_linux_test.go Show resolved Hide resolved
providers/linux/procnet_test.go Outdated Show resolved Hide resolved
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Just some minor comments. Overall LGTM.

providers/linux/host_linux.go Outdated Show resolved Hide resolved
@@ -0,0 +1,12 @@
cpu 31608779 223223 15924288 1134746753 223880 4348430 1995355 266903 0 0
Copy link
Member

Choose a reason for hiding this comment

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

I don't see where this file is being used in the PR. If it's not used then let's remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently the code will try and find a /proc/host file before it does anything else. Without this the test will fail.

providers/linux/host_linux.go Outdated Show resolved Hide resolved
providers/linux/procnet.go Outdated Show resolved Hide resolved
providers/linux/procnet.go Outdated Show resolved Hide resolved
providers/linux/procnet.go Outdated Show resolved Hide resolved
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Just one small thing I noticed. LGTM otherwise.

types/host.go Outdated Show resolved Hide resolved
@fearful-symmetry fearful-symmetry merged commit 4801f57 into elastic:master Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants