Skip to content

[network] Work around ss -atun bug not differentiating tcp and udp#296

Merged
zippolyte merged 7 commits into
masterfrom
hippolyte.henry/fix_ss_udp
Mar 29, 2017
Merged

[network] Work around ss -atun bug not differentiating tcp and udp#296
zippolyte merged 7 commits into
masterfrom
hippolyte.henry/fix_ss_udp

Conversation

@zippolyte

Copy link
Copy Markdown
Contributor

No description provided.

@olivielpeau olivielpeau self-assigned this Mar 27, 2017

@olivielpeau olivielpeau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had a comment on how we could simplify the logic, but overall I think calling ss 4 times is the correct approach.

Also, the CI is failing, on a flake8 thing. Let's fix it and also update the mock tests/fixtures to reflect what ss actually returns now.

Comment thread network/check.py Outdated
output, _, _ = get_subprocess_output(["ss", "-n", "-u", "-t", "-a", "-{0}".format(ip_version)], self.log)
lines = output.splitlines()
output_tcp, _, _ = get_subprocess_output(["ss", "-n", "-t", "-a", "-{0}".format(ip_version)], self.log)
output_udp, _, _ = get_subprocess_output(["ss", "-n", "-u", "-a", "-{0}".format(ip_version)], self.log)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this could be simplified by using a second for loop iterating on ['tcp', 'udp'] (or having one loop iterating over all 4 combinations of protocols/ip versions) and calling get_subprocess_output and _parse_linux_cx_state inside the loop. This should allow removing your specific code below that adds a header to each line and modifies the output of the command.

Feel free to change the signature and internal behavior of _parse_linux_cx_state, or remove it altogether if it doesn't make sense to use it anymore, it's only used for these ss and netstat calls.

@olivielpeau olivielpeau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks 👌 !

Let's merge this and double-check that the these metrics are flowing correctly when this is shipped to an actual environment.

@zippolyte
zippolyte merged commit 3b43f87 into master Mar 29, 2017
@zippolyte
zippolyte deleted the hippolyte.henry/fix_ss_udp branch March 29, 2017 15:51
gml3ff pushed a commit that referenced this pull request May 14, 2020
* Extract datadog tags into a template var
* Support strings and hashes
* Update docs for tag attribute
* Add test coverage for tags (string, hash, empty hash value)

Closes #186
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