Posted By

scarfboy on 08/12/08


socket networking netstat

Versions (?)

Summarize TCP socket states (using netstat)

 / Published in: Bash

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:

     21 tcp LISTEN
     12 tcp ESTABLISHED
      7 tcp6 LISTEN
      1 tcp TIME_WAIT

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

Report this snippet  

You need to login to post a comment.