Preview: Handy Netstat Commands

This is a preview, which will be updated as I collect a more comprehensive collection. Basically, I just want to publish this so I have it handy =P:

To get IPs grouped by number of connections :
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

To get a summation of the various states of connections (HTTP specific):
netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c

To get a summation of the various states of connections (all):
netstat -tan | awk '{print $6}' | sort | uniq -c

Original authors: concorde, sailorFred, from http://www.webhostingtalk.com/archive/index.php/t-493735.html

One Comment

Leave a Reply

XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>