系統管理員IRIX
監測IRIX系統 本章主題: l 支持性概念 - 理解IRIX進程 n 進程類型 n 進程表 n 進程特點 n 進程的活動周期 l 如何使用進程監測工具 - 監測系統行為: n ps n top, gr_top(在窗口環境下看) n osview n gr_osview(圖形化) n sar (system activity reporter) - 監測用戶 - 進程管理命令: n kill n npri, nice 4.1 進程類型 4.1.1. 交互進程: 與login, terminal or window session相關的進程, 如:jot, showcase, csh; 4.1.2. 批處理進程, 如:cron, batch, at; 4.1.3. 後台駐留程序進程(Daemons): 系統啟動時初始化的系統進程,在後台等待直至活動進程需要它們服務;其特點是: - 它與特定用戶或login無關; - 只進行系統任務,然後處於休眠狀態; 如:inetd, lpsched, biod, rpc.lockd 4.2 進程表 4.2.1. 何為進程表? 進程表指由內核所維護的系統進程表,它具有固定空間大小。 (通過 /var/sysgen/stune 來定制進程入口數目) 4.2.2. 如何使用進程表? 每建立一個新的進程,就在進程表中增加該進程唯一的進程標志碼(PID)和入口(entry)。 4.2.3. 進程表中包含哪些信息? - 進程標志碼(PID) - 進程調度(scheduling) - 資源使用狀況 4.3 進程主要特點 進程標志 UID 進程所有者的用戶ID PID 進程ID PPID 父進程ID TTY 進程的控制終端設備 CMD 命令名及參量 進程調度 PRI 進程的優先級 NI Nice value priority modifier P 正在運行本進程的處理器數目 資源使用狀態 CPU TIME 累計運行時間 STIME 進程起始時間 C 用於進程調度的處理器使用狀況 內存 SZ 程序總空間,以4K為單位 RSS 一個進程在4K頁面上的駐留空間 4.4 進程的活動周期 進程“血統” - 創建或產生新進程的進程稱為父進程; - 由父進程產生的新進程稱為子進程; 進程的生死過程 - 當父進程激發子進程後,自己去“睡眠”; - 新進程運行與父進程同樣的程序,但PID是新的; - 當子進程運行完畢時,子進程“死亡”,父進程被喚醒; 4.5 進程監測命令 4.5.1. ps ps用以查看進程表,主要命令有: #(%)ps #(%)ps -e 列出正在運行的所有進程 #(%)ps -l 長列表 #(%)ps -f 全列表 #(%)ps -u 為指定用戶列出進程表, 如:#ps -lfu guest
上述進程列表選項與進程特性顯示之間的關系: Identification e f l UID User ID of process owner 0 1 1 PID Process ID 1 1 1 PPID Parent Process ID 0 1 1 TTY Controlling terminal device for 1 1 1 the process CMD Command name 1 1 1 And arguments 0 1 0
Scheduling e f l PRI Priority of the process 0 0 1 NI Nice value priority modifier 0 0 1 P Processor number for a running 0 0 1 process Resource Utilization e f l cpu: TIME Cumulative execution time 1 1 1 STIME Starting time of the process 0 1 0 C Processor utilization for scheduling 0 1 1 memory: SZ Total size in 4K pages of the process 0 0 1 RSS Total(core) resident size in 4K 0 0 1 pages of a process
注:-e, -f, -l, -u等ps選項可組合使用,如 %ps -ef 4.5.2. top,gr_top 顯示特定時間間隔內進程使用CPU的狀況: #(%) top 以文本方式顯示 #(%) gr_top 以圖形方式顯示 (Xwindow) 4.5.3. osview,gr_osview 顯示特定時間間隔內進程使用系統資源的狀況: #(%) osview 以文本方式顯示 #(%) gr_osview 以圖形方式顯示 注:圖形顯示方式可由 ~/.grosview文件定制。 4.5.4. sar sar:system activity reporter 全面地進行系統行為統計。 命令格式: # sar –u <間隔時間> <次數> 其中間隔時間單位為秒,如: # sar –u 6 4 sar的選項用以顯示各種數據類型: - sar -u CPU utilization - sar -y TTY device activity - sar -c system calls - sar -w system swapping and switching activity - sar -g graphics activity - sar -a use of file access system routines - sar -d disk activity (block devices) - sar -b buffer activity - sar -p paging activities - sar -v states of process, i-node,file tables and record lock tables - sar -q avage queue length and % of time occupied - sar -h system heap activity - sar -m message and semaphore activity - sar -I Interrupt statistics - sar -r unused memory pages and disk blocks - sar -A gives you all possible information 用sar進行自動信息歸納。命令格式: # /etc/chkconfig sar on # /etc/init.d/perf # more /var/adm/sa/sar02