- 論壇徽章:
- 0
|
一臺服務(wù)器,一直報(bào)打開文件數(shù)過多。
想寫個(gè)腳本用lsof命令查找是那個(gè)用戶哪個(gè)進(jìn)程打開的文件數(shù)最多。
比如lsof出現(xiàn)的信息如下
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
init 1 root cwd DIR 8,2 4096 2 /
init 1 root rtd DIR 8,2 4096 2 /
init 1 root txt REG 8,2 43496 415811 /sbin/init
init 1 root mem REG 8,2 139416 575728 /lib64/ld-2.5.so
init 1 root mem REG 8,2 1717800 575729 /lib64/libc-2.5.so
init 1 root mem REG 8,2 23360 575731 /lib64/libdl-2.5.so
init 1 root mem REG 8,2 247496 575745 /lib64/libsepol.so.1
init 1 root mem REG 8,2 95464 575746 /lib64/libselinux.so.1
init 1 root 10u FIFO 0,17 2769 /dev/initctl
migration 2 root cwd DIR 8,2 4096 2 /
migration 2 root rtd DIR 8,2 4096 2 /
migration 2 root txt unknown /proc/2/exe
ksoftirqd 3 root cwd DIR 8,2 4096 2 /
ksoftirqd 3 root rtd DIR 8,2 4096 2 /
ksoftirqd 3 root txt unknown /proc/3/exe
migration 4 root cwd DIR 8,2 4096 2 /
migration 4 root rtd DIR 8,2 4096 2 /
migration 4 root txt unknown /proc/4/exe
ksoftirqd 5 root cwd DIR 8,2 4096 2 /
ksoftirqd 5 root rtd DIR 8,2 4096 2 /
ksoftirqd 5 root txt unknown /proc/5/exe
events/0 6 root cwd DIR 8,2 4096 2 /
events/0 6 root rtd DIR 8,2 4096 2 /
events/0 6 root txt unknown /proc/6/exe
events/1 7 root cwd DIR 8,2 4096 2 /
events/1 7 root rtd DIR 8,2 4096 2 /
那有什么方法可以自動(dòng)計(jì)算每個(gè)進(jìn)程打開了多少文件,并根據(jù)打開文件的數(shù)量自動(dòng)排序? |
|