2016-08-03 31 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