lsof查进程连接等

参考:

https://www.cnblogs.com/bonelee/p/7735479.html

#查看打开文件数

lsof |wc -l

#查看某个进程打开的文件数

lsof -p 19764|wc -l

lsof -p 19764|more

1.列出所有打开的文件:
lsof
2. 查看谁正在使用某个文件
lsof /filepath/file
5. 列出某个用户打开的文件信息
lsof -u username
6. 列出某个程序所打开的文件信息
lsof -c mysql
8. 列出某个用户以及某个程序所打开的文件信息
lsof -u test -c mysql
13 . 列出所有的网络连接
lsof -i
14. 列出所有tcp 网络连接信息
lsof -i tcp
15. 列出所有udp网络连接信息
lsof -i udp
16. 列出谁在使用某个端口
lsof -i :3306

#查看连接数:
netstat -n |grep TIME|awk '{print $5}' |cut -d: -f1|sort |uniq -c |sort -n

一、查看哪些IP连接本机
netstat -an

二、查看TCP连接数
1)统计80端口连接数
netstat -nat|grep -i "80"|wc -l
2)统计httpd进程数
ps -ef|grep httpd|wc -l
3)、统计已连接上的,状态为“established
netstat -na|grep ESTABLISHED|wc -l
查出哪个IP地址连接最多
netstat -na|grep ESTABLISHED|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -r

将最多的封了.
netstat -na|grep SYN|awk {print $5}|awk -F: {print $1}|sort|uniq -c|sort -r +0n

 4) 查看某个ip的连接数

netstat -ant | grep 161.50|wc -l

#查看进程打开文件限制,先获得pid

cat /proc/2283/limits
Limit Soft Limit Hard Limit Units 
Max cpu time unlimited unlimited seconds 
Max file size unlimited unlimited bytes 
Max data size unlimited unlimited bytes 
Max stack size 10485760 unlimited bytes 
Max core file size unlimited unlimited bytes 
Max resident set unlimited unlimited bytes 
Max processes 63316 63316 processes 
Max open files 1000000 1000000 files 
Max locked memory 65536 65536 bytes 
Max address space unlimited unlimited bytes 
Max file locks unlimited unlimited locks 
Max pending signals 63316 63316 signals 
Max msgqueue size 819200 819200 bytes 
Max nice priority 0 0 
Max realtime priority 0 0 
Max realtime timeout unlimited unlimited us

猜你喜欢

转载自www.cnblogs.com/hongfeng2019/p/12168904.html