-
Notifications
You must be signed in to change notification settings - Fork 814
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
Conversation
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
Thanks! |
ok thanks. |
# 165400 duplicate acks | ||
# ... | ||
metrics = { | ||
re.compile("^\s*(\d+) data packets \(\d+ bytes\) retransmitted\s*$"): 'system.net.tcp.retrans_packs', |
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.
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.
@@ -11,7 +11,17 @@ | |||
# project | |||
from checks import AgentCheck | |||
from util import Platform | |||
BSD_TCP_METRICS = { |
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.
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:
Add new network metrics to get information about tcp retransmits and tcp packets in/out