Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
Last active August 29, 2015 14:00
Show Gist options
  • Save metalrufflez/8632ce1afc957261f708 to your computer and use it in GitHub Desktop.
Save metalrufflez/8632ce1afc957261f708 to your computer and use it in GitHub Desktop.
Count all TCP connections for a given port
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