82 5 監控程序

2021-09-22 17:05:11 字數 4930 閱讀 1946

列出某個程式程序所開啟的檔案資訊,顯示httpd程序現在開啟的檔案

lsof -c httpd
顯示多個程序命令用法

[root@netkiller ~]# lsof -c smbd

command pid user fd type device size/off node name

smbd 2506 root cwd dir 8,2 4096 2 /

smbd 2506 root rtd dir 8,2 4096 2 /

smbd 2506 root txt reg 8,2 10112200 3935771 /usr/sbin/smbd

[root@netkiller ~]# lsof -c smbd -c httpd

-p 程序id, 顯示該程序開啟了那些檔案

lsof -p 1782顯示程序id

# lsof -t -u apache

4374

4375

4376

4377

4378

4379

4380

列出某個程式號開啟的檔案

httpd 2374 root mem reg 8,2 90784 5636110 /lib64/libgcc_s-4.4.7-20120601.so.1

監控多個程序id

[root@netkiller neo]# lsof -p 20535,26359,31462 | more

command pid user fd type device size/off node name

nginx 20535 root cwd dir 253,1 4096 2 /

nginx 20535 root rtd dir 253,1 4096 2 /

nginx 20535 root txt reg 253,1 1066704 142069 /usr/sbin/nginx

nginx 20535 root del reg 0,4 686393039 /dev/zero

nginx 20535 root mem reg 253,1 61928 162109 /usr/lib64/libnss_files-2.17.so

nginx 20535 root mem reg 253,1 153192 151546 /usr/lib64/liblzma.so.5.0.99

nginx 20535 root mem reg 253,1 147120 133015 /usr/lib64/libselinux.so.1

nginx 20535 root mem reg 253,1 110808 162113 /usr/lib64/libresolv-2.17.so

nginx 20535 root mem reg 253,1 15688 134676 /usr/lib64/libkeyutils.so.1.5

nginx 20535 root mem reg 253,1 62720 158030 /usr/lib64/libkrb5support.so.0.1

nginx 20535 root mem reg 253,1 202576 137049 /usr/lib64/libk5crypto.so.3.1

nginx 20535 root mem reg 253,1 15840 133029 /usr/lib64/libcom_err.so.2.1

nginx 20535 root mem reg 253,1 950496 137059 /usr/lib64/libkrb5.so.3.3

nginx 20535 root mem reg 253,1 316528 151679 /usr/lib64/libgssapi_krb5.so.2.2

nginx 20535 root mem reg 253,1 11376 151527 /usr/lib64/libfreebl3.so

nginx 20535 root mem reg 253,1 2112384 132823 /usr/lib64/libc-2.17.so

nginx 20535 root mem reg 253,1 90632 133017 /usr/lib64/libz.so.1.2.7

nginx 20535 root mem reg 253,1 2016880 132882 /usr/lib64/libcrypto.so.1.0.1e

nginx 20535 root mem reg 253,1 449904 137215 /usr/lib64/libssl.so.1.0.1e

nginx 20535 root mem reg 253,1 398264 160788 /usr/lib64/libpcre.so.1.2.0

nginx 20535 root mem reg 253,1 40816 151198 /usr/lib64/libcrypt-2.17.so

nginx 20535 root mem reg 253,1 142304 132849 /usr/lib64/libpthread-2.17.so

nginx 20535 root mem reg 253,1 19520 162101 /usr/lib64/libdl-2.17.so

nginx 20535 root mem reg 253,1 164440 132816 /usr/lib64/ld-2.17.so

nginx 20535 root del reg 0,4 686393042 /dev/zero

nginx 20535 root 0u chr 1,3 0t0 1028 /dev/null

nginx 20535 root 1u chr 1,3 0t0 1028 /dev/null

排除1,4,顯示2,3,5

[root@netkiller neo]# lsof -p ^1,2,3,^4,5

command pid user fd type device size/off node name

kthreadd 2 root cwd dir 253,1 4096 2 /

kthreadd 2 root rtd dir 253,1 4096 2 /

kthreadd 2 root txt unknown /proc/2/exe

ksoftirqd 3 root cwd dir 253,1 4096 2 /

ksoftirqd 3 root rtd dir 253,1 4096 2 /

ksoftirqd 3 root txt unknown /proc/3/exe

kworker/0 5 root cwd dir 253,1 4096 2 /

kworker/0 5 root rtd dir 253,1 4096 2 /

kworker/0 5 root txt unknown /proc/5/exe

8 2 5 例項分析

下面對以上 作簡要說明 1 按照常規步驟建立並拷貝 matrix rect 的matrx var mymatrix matrix matrix rect.transform.matrix 此處應該注意大小寫,transform 內部並不存在 matrix 物件。matrix 是矩陣類的名字,matr...

linux 程序監控

1 ps命令 直接在linux系統中輸入 ps 結果如下 預設情況下,ps命令指揮顯示執行在當前控制台下的屬於當前使用者的程序。pid 程式的程序號 tty 程式執行的終端 time 程式執行的時間 引數 在linux系統中,程序的狀態有五種 1.執行 正在執行或在執行佇列中等待 2.中斷 休眠中,...

supervise 程序監控

daemontools讓程序保持通話 linux下程序有時候會莫名的斷掉,我在使用舊版mysql proxy的時候就時常被問題困惱,俗話說 不怕賊偷,就怕賊惦記著 程序斷掉並不可怕,可怕的是沒有任何先兆,稀里糊塗的就斷了,究其原因,一來可能是誤操作引起來的,二來可能是軟體本身的bug造成的,三來也可...