The following sums up all connections (ESTABLISHED, TIME_WAIT, FIN_WAIT, etc.) and sorts it:
netstat -n | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Works on FreeBSD and Linux.
Posted by Thomas Eisenbarth to makandra dev (2016-02-26 10:26)