Return to Snippet

Revision: 7771
at August 12, 2008 10:09 by scarfboy


Updated Code
netstat -nal |egrep '^tcp' | sed -r 's/[ ]+/ /g' | cut -d ' ' -f 1,6 | sort | uniq -c | sort -rn

Revision: 7770
at August 12, 2008 10:08 by scarfboy


Initial Code
netstat -nal |egrep '^tcp' | \
  sed -r 's/[ ]+/ /g' | cut -d ' ' -f 1,6 | sort | uniq -c | sort -rn

Initial URL


Initial Description
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:<tt><pre>     21 tcp LISTEN
     12 tcp ESTABLISHED
      7 tcp6 LISTEN
      1 tcp TIME_WAIT</pre></tt>

Initial Title
Summarize TCP socket states (using netstat)

Initial Tags


Initial Language
Bash