Skip to content

Instantly share code, notes, and snippets.

@ElijahLynn
Last active January 20, 2024 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElijahLynn/501e556b450cd6bfc868c384ca742155 to your computer and use it in GitHub Desktop.
Save ElijahLynn/501e556b450cd6bfc868c384ca742155 to your computer and use it in GitHub Desktop.
Monitor the number of all TCP connection states
watch -n 1 "netstat -an | awk '/^tcp/ { ++S[\$NF] } END { for(a in S) print a, S[a] }'"
# Every 1.0s: netstat -an | awk '/^tcp/ { ++S[$NF] } END { for(a in S) print a, S[a] }'
# LISTEN 7
# FIN_WAIT_2 1
# CLOSE_WAIT 1
# CLOSED 33
# TIME_WAIT 1
# ESTABLISHED 63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment