Sunday, July 31, 2016

Group All established connections by target IP

here is a very common case that you want to check whether you have even connection for a distributed system on the server side. or whether the client send the requests cross all server endpoints.

Basic idea. netstat -an|grep 'EST' will show you all the established connection.

so the 4th column is the client endpoints, and 5th column is the target one.

if we want to see how many connection for each Target as a IP. you can do the following command.
netstat -an -p tcp|grep "EST"|awk '{print $5}'|awk -F "." '{print $1"."$2"."$3"."$4 }'|sort |uniq -c |sort -n -r
and if we only want to see the top 5.  we can put rows index for the awk hint. 
netstat -an -p tcp|grep "EST"|awk '{print $5}'|awk -F "." 'FNR<6 {print $1"."$2"."$3"."$4 }'|sort |uniq -c |sort -n -r





1 comment:

naresh said...

Hi.

Thank You for sharing this information, this blog was Great! It gives good information to us thank for sharing this information with us.

I have seen same kind of information and it will help to you.

Salesforce Service Cloud Training

 
Locations of visitors to this page