Shell Statistics current network connection status

Source: Internet
Author: User

When the number of TCP connections is very large, the current internal IP, the connection of the external IP is counted

[[email protected] account_tcp]# cat account_tcp.sh #!/bin/bash# Statistics the current network connection situation Netstat  -na | awk  '/^tcp/{s[$6]++}end{for (key in s) Print key,s[key]} '  >  /root/account_tcp/state.txt# statistics local address TCP connection number netstat -na | awk  '/^tcp/'  | awk -v fs= "[ :]+"   ' {print $4} '  | sort | uniq -c  | sort -n > /root/account_tcp/local_address.txt# statistics IP is 51 foreign  Address TCP connection Condition netstat -na | awk  '/^tcp/'  | grep 192.168.10.51 |  Awk -v fs= "[ :]+"   ' {print $6} '  | sort | uniq -c |  sort -n > /root/account_tcp/51_tcp.txt# TCP connectivity for the foreign address with the statistics IP 80 netstat -na  | awk  '/^tcp/'  | grep 192.168.10.80 | awk -v fs= "[ :]+ "  ' {print $6} '  |&Nbsp;sort | uniq -c | sort -n > /root/account_tcp/80_tcp.txt# TCP connectivity for foreign address with IP 86 netstat -na | awk  '/^tcp/'  | grep  192.168.10.86 | awk -v fs= "[ :]+"   ' {print $6} '  | sort |  uniq -c | sort -n > /root/account_tcp/86_tcp.txt# Statistics IP is 87 foreign  Address TCP connection Condition netstat -na | awk  '/^tcp/'  | grep 192.168.10.87 |  Awk -v fs= "[ :]+"   ' {print $6} '  | sort | uniq -c |  Sort -n > /root/account_tcp/87_tcp.txt


This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1909106

Shell Statistics current network connection status

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.