Skip to content

Instantly share code, notes, and snippets.

@schneefisch
Last active September 27, 2020 17:35
Show Gist options
  • Save schneefisch/ff3552dde57772a2523d7a72fd7a8825 to your computer and use it in GitHub Desktop.
Save schneefisch/ff3552dde57772a2523d7a72fd7a8825 to your computer and use it in GitHub Desktop.
basics for netstat
# check active connections
netstat -ant | grep 4444 | wc -l
# only established connections
netstat -ant | grep 4444 | grep -i established | wc -l
# idle connections
netstat -an -f inet | grep -v EST | grep IDLE | wc -l
# in loop
while true; do clear; netstat -an -f inet | awk '{print $2}' | cut -d. -f1-4 | sort | uniq -c | sort -n | grep -v "*.*" | tail -10; sleep 5; done
# show overall open connections on the server
while true; do clear; netstat -an -f inet | awk '{print $2}' | cut -d. -f1-4 | wc -l; sleep 5; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment