Summarize TCP socket states (using netstat)


/ Published in: Bash
Save to your folder(s)

Filters for tcp and tcp6 lines, so omits udp and unix sockets.

Information is gathered from /proc; this uses netstat mainly to format it.

Gives output like:<pre> 21 tcp LISTEN
12 tcp ESTABLISHED
7 tcp6 LISTEN
1 tcp TIME_WAIT</pre>


Copy this code and paste it in your HTML
  1. netstat -nal |egrep '^tcp' | sed -r 's/[ ]+/ /g' | cut -d ' ' -f 1,6 | sort | uniq -c | sort -rn

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.