命令

1
2
3


cat test.top.log |cut -d ' ' -f 1 | sort |uniq -c | sort -nr | awk '{print $0 }' | head -n 10

1
2
3


cat access.log | awk '{print $1}' | sort |uniq -c | sort -nr | head -n 10

查看linux中的TCP连接

1. 查看哪些IP连接本机

1
2
3


netstat -npt

2. 查看TCP连接数

统计80端口连接数

1
2
3


netstat -nat|grep -i "80"|wc -l

统计httpd协议连接数

1
2
3


ps -ef | grep httpd | wc -l

统计nginx协议连接数

1
2
3


ps -ef | grep nginx | wc -l

统计已连接上的,状态为“established

1
2
3


netstat -npt | grep ESTABLISHED | wc -l

3. 查看TCP的创建时间

1
2
3
4
5
6
7
8
9


netstat -npt | grep <PORT> 


lsof -p <PID> | grep <PORT>


ll /proc/<PID>/fd/<fd>

统计PV

1
2
3


cat buyer-api-2022-11-04-access.log | sed -n '/03\/Feb\/2022/p' | wc -l

统计UV

1
2
3


awk '{print $1}' buyer-api-2022-11-04-access.log|sort | uniq -c |wc -l

统计每个IP访问次数

1
2
3


awk '{print $1}' buyer-api-2022-11-04-access.log|sort | uniq -c