我正在寻求帮助,以便在Linux上编写一个Shell脚本来监控其他服务器的TCP连接。每隔一个小时,此脚本都会将TCP连接数超过100的服务器的名称列表输出到一个文本文件中。对此有什么想法吗?谢谢。
发布于 2014-03-03 22:58:33
Each hour:
(can be done by a cron job)
Log in on each server and:
(can be done by ssh with pre-installed keys)
list all TCP connections
(can be done by netstat or cat /proc/net/tcp or similar)
count them
(can be done by wc)例如:
for host in $(cat hostnames)
do
n=$(ssh "$host" 'cat /proc/net/tcp | wc -l')
[ "$n" -gt 100 ] && echo "$host: $n connections"
done >> logfile.txt发布于 2014-03-04 12:25:30
特定网络接口的
sudo tcpdump -i eth0 -n -q > /tmp/ccc 2>&1
>.//g'|sort|uniq
https://stackoverflow.com/questions/22149330
复制相似问题