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

Additional tcp metrics #949

Merged
merged 12 commits into from May 20, 2014
Merged

Additional tcp metrics #949

merged 12 commits into from May 20, 2014

Conversation

bunelr
Copy link
Contributor

@bunelr bunelr commented May 15, 2014

Add new network metrics to get information about tcp retransmits and tcp packets in/out

Rudy added 6 commits May 13, 2014 15:10
Parse the results from nestat summary which is not ideal
I have tried to use ctype and make calls to sysctl which is what netstat
does under the hood but the values were not correct and this works

tested on Mac OSX and on a OpenBSD 5.3 VM
Tested on a Solaris 11 VM from Oracle
@remh
Copy link
Contributor

remh commented May 19, 2014

Thanks!
Quick question, can we access these metrics using psutil ? https://pythonhosted.org/psutil/

@bunelr
Copy link
Contributor Author

bunelr commented May 19, 2014

Not really. You can get the numbers of open connections that we already connect by parsing netstat with this, which may or may not be worth replacing by psutil or you can get non TCP specific counters with this but nothing about the TCP retransmits that we're looking for

@remh
Copy link
Contributor

remh commented May 19, 2014

ok thanks.

# 165400 duplicate acks
# ...
metrics = {
re.compile("^\s*(\d+) data packets \(\d+ bytes\) retransmitted\s*$"): 'system.net.tcp.retrans_packs',
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make the compiled regex constants at the module level ?
This way they would get compiled only once which is a good practice as regex compiling is a bit CPU consuming.

@remh remh added this to the 4.3.x milestone May 19, 2014
@@ -11,7 +11,17 @@
# project
from checks import AgentCheck
from util import Platform
BSD_TCP_METRICS = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiny perf nitpick, you shouldn't use a dictionary here as you are not going to query it by the keys.

It should be a list of tuples:

BSD_TCP_METRICS = [
      (re.compile("^\s*(\d+) data packets \(\d+ bytes\) retransmitted\s*$"), 'system.net.tcp.retrans_packs'),
      (re.compile("^\s*(\d+) packets sent\s*$"), 'system.net.tcp.sent_packs'),
      (re.compile("^\s*(\d+) packets received\s*$"), 'system.net.tcp.rcv_packs'),
]

and then you'll be able to iterate with:

for regex, metric_name in BSD_TCP_METRICS:

@remh remh merged commit 73ccea7 into master May 20, 2014
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.

None yet

2 participants