OpenTSDB / tcollector

Data collection framework for OpenTSDB
http://opentsdb.net
GNU Lesser General Public License v3.0
513 stars 359 forks source link

add TCP(IPv4 + IPv6) socket state metrics #463

Closed meow-watermelon closed 6 months ago

meow-watermelon commented 2 years ago

This PR adds detailed TCP socket state count metrics. Output example:

...
net.tcp_state.established 1652153830 47 type=tcp
net.tcp_state.syn_sent 1652153830 0 type=tcp
net.tcp_state.syn_recv 1652153830 0 type=tcp
net.tcp_state.fin_wait1 1652153830 0 type=tcp
net.tcp_state.fin_wait2 1652153830 0 type=tcp
net.tcp_state.time_wait 1652153830 5 type=tcp
net.tcp_state.close 1652153830 0 type=tcp
net.tcp_state.close_wait 1652153830 1 type=tcp
net.tcp_state.last_ack 1652153830 0 type=tcp
net.tcp_state.listen 1652153830 5 type=tcp
net.tcp_state.closing 1652153830 0 type=tcp
net.tcp_state.new_syn_recv 1652153830 0 type=tcp
net.tcp_state.max_states 1652153830 0 type=tcp
net.tcp_state.established 1652153830 22 type=tcp6
net.tcp_state.syn_sent 1652153830 0 type=tcp6
net.tcp_state.syn_recv 1652153830 0 type=tcp6
net.tcp_state.fin_wait1 1652153830 0 type=tcp6
net.tcp_state.fin_wait2 1652153830 0 type=tcp6
net.tcp_state.time_wait 1652153830 1 type=tcp6
net.tcp_state.close 1652153830 0 type=tcp6
net.tcp_state.close_wait 1652153830 0 type=tcp6
net.tcp_state.last_ack 1652153830 0 type=tcp6
net.tcp_state.listen 1652153830 3 type=tcp6
net.tcp_state.closing 1652153830 0 type=tcp6
net.tcp_state.new_syn_recv 1652153830 0 type=tcp6
net.tcp_state.max_states 1652153830 0 type=tcp6

The type indicates if the metric is from IPv4(tcp) or IPv6(tcp6) socket.

meow-watermelon commented 2 years ago

@johann8384 @tsuna could you please take a look? Thanks.

meow-watermelon commented 1 year ago

@manolama could you please take a look? Thanks

vasiliyk commented 6 months ago

Thank you for contributing!

Right now I see the following error that netstat collector produces: "Unrecoginized line in /proc/net/netstat: ['MPTcpExt:'". As I understand it is Multipath TCP. I need to fix it before adding the enhancement. Are you interested in fixing it?

meow-watermelon commented 6 months ago

hi @vasiliyk sure, i will do the fix soon. i think because it's been almost 2 years so need some adjustments.

vasiliyk commented 6 months ago

Merged with commits https://github.com/OpenTSDB/tcollector/commit/0317149bd7d914e95bdc846a01c8c5176e48d9a6 and https://github.com/OpenTSDB/tcollector/commit/ce0947257f08ecfedc52147ed1061420375c9cb1.