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
tools/tcpconnect: add option -c to count connects #2475
Conversation
[buildbot, test this please] |
[buildbot, ok to test] |
man/man8/tcpconnect.8
Outdated
@@ -25,6 +25,9 @@ Print usage message. | |||
\-t | |||
Include a timestamp column. | |||
.TP | |||
\-c | |||
Count connects per dest ip/port. |
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 use "connections" here, which is more common usage, instead of "connects"? Same for below several other cases.
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.
"connects" may be more accurate than connections in this context? because we inspect the connect actions, not any already established connections.
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.
We could use "new connections" or "connects". I guess "connect" okay which is short and also captures the essence.
man/man8/tcpconnect.8
Outdated
.TP | ||
Trace UID 1000 only: | ||
# | ||
.B tcpconnect \-u 1000 | ||
.TP | ||
Count connects per dest ip/port: |
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.
It should be source ip + dest ip/port?
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.
yes. will fix it
tools/tcpconnect.py
Outdated
""" | ||
struct ipv6_flow_key_t flow_key = {}; | ||
flow_key.saddr = skp->__sk_common.skc_rcv_saddr; | ||
flow_key.daddr = skp->__sk_common.skc_daddr; |
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.
The above to calculate ipv6 src/dest addresses are not correct. Do you have environment to test it?
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.
copy and paste error. will fix it.
3a758b8
to
27a7a9e
Compare
Thanks for the fix. I have one more request for this.
You can see ipv4 and ipv6 addresses are printed differently. |
FWIW, I would not want to see this behavior added to all the tools. That the tools are (or were) simple and have a single function is a benefit that aids learning, and makes them double as code examples. I'd add switches like this only when necessary. |
Add -c to count all active connections per dest ip/port so we can easily spot the heavy outbound connection attempts. # ./tcpconnect.py -c Tracing connect ... Hit Ctrl-C to end ^C LADDR RADDR RPORT CONNECTS 192.168.10.50 172.217.21.194 443 70 192.168.10.50 172.213.11.195 443 34 192.168.10.50 172.212.22.194 443 21 [...]
Got your point. Plan is to integrate various BCC tools into production monitoring systems. So '-c' will make tcpconnect(maybe other tools as well) more efficient and more succinct. Personally I think this feature will be useful to others too. |
OK. Resubmitted. |
Looks good. Thanks! |
Add -c to count all active connections per dest ip/port so we can
easily spot the heavy outbound connection attempts.