Last active
August 29, 2015 14:00
-
-
Save metalrufflez/8632ce1afc957261f708 to your computer and use it in GitHub Desktop.
Count all TCP connections for a given port
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function count_conns() { | |
if [[ $# -eq 0 ]]; then | |
echo "Usage: $FUNCNAME <port>" | |
return | |
fi | |
ss -t -n "src :$1" | awk '{print $5}' | sed 1d | sort | cut -d: -f1 | uniq -c | sort -k1,1nr -t. -k2,2n -k3,3n -k4,4n -k5,5n | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment