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