2016-08-03 33 views

回答

0

您可以使用/usr/bin/timex

the /usr/bin/timex man page

執行給定的命令;以秒爲單位報告所用時間,用戶時間和系統執行時間。任選地,該命令處理 會計數據和它的所有子可列出或 總結,並執行間隔 期間總系統活動可以被報告。

...

的命令列表-p進程記賬記錄及其所有子。 只有在安裝了進程記賬軟件後,此選項纔有效。子選項f,h,k,m,r和t修改報告的數據項目 。選項如下:

...

開始與該男子頁acctadm得到啓用進程記帳。

注意,在Solaris上,getrusage()wait3()不返回內存使用統計信息。看到http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/syscall/rusagesys.c的(有些過時)getrusage()源代碼,並在http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/sys/common/wait.c#158wait3()源代碼(這實際上是OpenSolaris源代碼,甲骨文下跌的支持,它可能不能代表當前的Solaris實現,但在Solaris 11.2一些測試表明, RSS數據實際上仍爲零)

此外,從Solaris getrusage() man page

ru_maxrss,所述 rusage結構的ru_ixrssru_idrss,和ru_isrss成員在該實施方式中設定爲0。

幾乎可以肯定有其他方法來獲取數據,如dtrace

編輯:

dtrace不看太大的幫助,很遺憾。試圖用dtrace -s memuse.d -c bash

#!/usr/sbin/dtrace -s 

#pragma D option quiet 

profile:::profile-1001hz 
/pid == $target/
{ 
    @pct[ pid ] = max(curpsinfo->pr_pctmem); 
} 

dtrace:::END 
{ 
    printa("pct: %@u %a\n", @pct); 
} 

導致以下錯誤信息運行此腳本dtrace

dtrace: failed to compile script memuse.d: line 8: translator does not define conversion for member: pr_pctmem 

在Solaris dtrace似乎並沒有提供對進程的內存使用。實際上,Solaris 11。2 /usr/lib/dtrace/procfs.d翻譯爲procfs數據中有此評論:

/* 
* Translate from the kernel's proc_t structure to a proc(4) psinfo_t struct. 
* We do not provide support for pr_size, pr_rssize, pr_pctcpu, and pr_pctmem. 
* We also do not fill in pr_lwp (the lwpsinfo_t for the representative LWP) 
* because we do not have the ability to select and stop any representative. 
* Also, for the moment, pr_wstat, pr_time, and pr_ctime are not supported, 
* but these could be supported by DTrace in the future using subroutines. 
* Note that any member added to this translator should also be added to the 
* kthread_t-to-psinfo_t translator, below. 
*/ 

瀏覽Illumos.org源代碼,搜索ps_rssize,表示在需要時procfs數據僅計算,而不是不斷更新的過程中運行。 (見http://src.illumos.org/source/search?q=pr_rssize&defs=&refs=&path=&hist=&project=illumos-gate