Skip to content

Too many connections in Linux

1、在连接数报警的机器上,查看某个端口tcp连接来源,并排序

netstat -natl |grep ^tcp |grep ":443" |awk '{print $5}' |awk -F":" '{count[$1]++}; END{for(ip in count) print ip, ": " count[ip]}' |sort -n -k3 -r

2、找到最多的tcp对应的机器,在那台机器上查看哪个进程占用最多连接

netstat -nap |grep ":443" |awk '{print $7}' |awk -F"/" '{print $1}' | sort | uniq -c | sort -nr

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback me#imzye.me, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try iOS App