-
Notifications
You must be signed in to change notification settings - Fork 320
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
support to read from /proc/net/tcp{,6} #332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM beside minor nits.
Can you fix the DCO with |
Signed-off-by: Andrei Volnin <wolandr@gmail.com> Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
Signed-off-by: Hubert Chen <hubert@branchmetrics.io>
This is causing the node_exporter to crash. :-(
|
Sorry. Will take a look today. |
@SuperQ I built and ran the node_exporter master on amd64 linux with 3.x and 4.x kernels and didn't see any issues. I noticed that node_exporter end-to-end-test.sh was skipping the test because there was no udp6 fixtures. When I add the fixtures from procfs it also didn't crash. I did a circleci build and it passed tests and built all the cross compiled binaries fine. What environment did you see the crash in? How can I replicate it? |
We should not return a nil pointer if the fixtures don't exist. That edge case needs to be handled. |
* Add GIDs to ProcStatus struct Signed-off-by: Andrei Volnin <wolandr@gmail.com> * support to read from /proc/net/tcp{,6} Signed-off-by: Hubert Chen <hubert@branchmetrics.io> Co-authored-by: Andrei Volnin <wolandr@gmail.com>
This provides support to read from /proc/net/tcp and /proc/net/tcp6. Which had originally been done with #20, but that was considered out of date, so @SuperQ suggested I open a new PR.
This change is not as extensive as it looks.
Because /proc/net/tcp{,6} is identical to /proc/net/udp{,6} and udp support already exists in net_udp.go, I went and refactored the net_udp.go to create a new set of base classes in net_ip_socket.go that could be used for both net_udp.go and net_tcp.go.
I moved most of the test code from net_udp_test.go and into net_ip_socket_test.go. I replicated the existing net_udp_test.go tests into net_tcp_test.go, and added a new tcp fixture identical to the udp one. I validated that the old UDP tests still work and new identical TCP tests also work.
I'm happy to rewrite this in a different way if people don't think this is a good idea. I had considered doing a copy of the existing net_udp.go code and just changing names to support TCP, but thought this was a bit more reusable if formats change or bugs are uncovered they would likely apply to both tcp and udp.