- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我试图监控子进程的内存使用峰值。time -v 是一个选项,但它在 solaris 中不起作用。那么有什么方法可以从 shell 脚本中获取 usage 结构中的详细信息?
最佳答案
你可以使用/usr/bin/timex
来自 the /usr/bin/timex
man page :
The given command is executed; the elapsed time, user time and system time spent in execution are reported in seconds. Optionally, process accounting data for the command and all its children can be listed or summarized, and total system activity during the execution interval can be reported.
...
-p List process accounting records for command and all its children. This option works only if the process accounting software is installed. Suboptions f, h, k, m, r, and t modify the data items reported. The options are as follows:
...
从 acctadm
的手册页开始启用进程记帐。
请注意,在 Solaris 上,getrusage()
和 wait3()
不返回内存使用统计信息。在 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/syscall/rusagesys.c 查看(有点过时的)getrusage()
源代码和 wait3()
源代码位于 http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/sys/common/wait.c#158 (这实际上是 OpenSolaris 源,Oracle 放弃了对它的支持,它可能不代表当前的 Solaris 实现,尽管对 Solaris 11.2 的一些测试表明 RSS 数据实际上仍然为零。)
此外,来自 Solaris getrusage()
man page :
The
ru_maxrss
,ru_ixrss
,ru_idrss
, andru_isrss
members of therusage
structure are set to 0 in this implementation.
几乎可以肯定还有其他方法可以获取数据,例如 dtrace
。
编辑:
不幸的是,dtrace
看起来没什么用。尝试使用 dtrace -s memuse.d -c bash
dtrace
脚本
#!/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: failed to compile script memuse.d: line 8: translator does not define conversion for member: pr_pctmem
Solaris 上的
dtrace
似乎不提供对进程内存使用情况的访问。事实上,procfs
数据的 Solaris 11.2 /usr/lib/dtrace/procfs.d
转换器中有这样的注释:
/*
* 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)
关于linux - 是否有 wait3 的替代方法来在 shell 脚本中获取 usage 结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38735793/
我有以下 Java 代码: public static void fun(int[] a) { int min; for(int j=0;j
我每天都在使用 PHPStorm 中出色的查找用法功能,搜索结果属于以下两个类别之一: 非代码用法 发现用法 我几乎对非代码用法不感兴趣。此外,当我寻找名为 get() 或 set() 的方法的用法时
我正在尝试在 Visual Studio 中分析我的 UWP(通用 Windows 平台)应用程序,以查看导致我的进程内存使用率如此之高的原因。 我一直在使用 Visual Studio 的内置诊断工
这个问题可能也适用于其他库,但是使用 Cassandra 作为一个具体的例子来确保我问的是一个可以回答的问题: 使用 Kotlin,我可以使用 Cassandra 的异步方法,然后用 Listenab
我正在开发一个简单的命令行工具,但我发现默认的 Usage 消息有点欠缺。我想定义我自己的,我认为我做对了我指的是 this example . 我注释掉了我编写的大部分代码,因此包含 main 函数
我正在从应用程序 A 向 Artemis 发送消息,但我从应用程序 A 收到此错误: AMQ212054: Destination address=my-service is blocked. If
我正在从应用程序 A 向 Artemis 发送消息,但我从应用程序 A 收到此错误: AMQ212054: Destination address=my-service is blocked. If
我阅读了有关在 PostgreSQL 中授予序列的答案。通常,他们说同时授予 SELECT、USAGE。我想知道我是否可以只授予 USAGE。哪一个是授予序列的最佳实践,为什么? 最佳答案 Quote
我正在尝试查看我的使用计划中每个 API key 的使用情况。但是当我跑 aws apigateway get-usage --usage-plan-id ***** --start-date 202
我正在使用 Spring Boot 2.3.2。在执行器的帮助下,将应用程序指标发布到指标控制台。我想知道 system.cpu.usage 和有什么区别和 process.cpu.usage执行器优
将 Xamarin.Forms iOS 应用提交到 Apple 的 TestFlight 后,我们收到以下消息。 消息: Dear Developer, We identified one or
我想捕获以下参数: lastAccessedTime - 用户上次访问站点的时间(通常在登录过程中显示) isOnline - 表示用户是否在线的 bool 值。 一种。将这些变量作为用户表本身的一部
我的Web服务器上偶尔有HTTPD请求,这会增加CPU使用率。我在顶部观看此视频。每个URL都是在每次请求时动态生成的。该框架是Codeigniter。我正在使用prefork Apache作为Lin
我们有一个非常小的专业用户群。 没有社区。 我的老板想找出谁在使用它。他的方法是简单地建立一个隐藏的连接,也许是一个自动更新功能,默认情况下在没有更新的情况下启用WITHOUT通知... 我不太喜欢这
我正在尝试监视安装和运行Prometheus的计算机的cpu利用率。我有一个指标'process_cpu_seconds_total'。我可以找到该指标的评分或评分。但是我不太确定如何得出CPU利用率
是否可以估计单个进程在运行时产生的热量。 处理器的温度读数很容易获得,但我需要的是进程特定的信息。 是否可以映射 CPU 利用率、IO、运行时间、内存使用等信息来获得某种估计? 最佳答案 我要说不。因
当一个内核的 CPU 使用率为 100% 时,这意味着什么? 这是否意味着进程已经达到了内核的最大可能性能(使用矢量化),还是意味着 CPU 正在执行与内核时钟一样多的周期? 另外,如果它是 100%
这个问题已经有答案了: some macro statements may have unexpected results in C++? (3 个回答) 已关闭 9 年前。 以下脚本的输出是 20。
我似乎无法使用 JSON::XS的OO接口(interface)正常。以下呱呱叫我无法追踪的错误: use JSON::XS; my $array = ['foo', 'bar']; my $code
我希望我们的应用程序在第一次启动时向服务器发送一些匿名信息(操作系统、Java 版本等)。唯一的用途是确定正在使用的副本数量,并了解我们的客户最常使用哪些操作系统,以便我们知道将测试重点放在何处。 我
我是一名优秀的程序员,十分优秀!