子プロセスのピークメモリ使用量を監視しようとしていました.time -vはオプションですが、solarisでは機能しません.シェルスクリプトからrusage構造の詳細を取得する方法はありますか?
1 に答える
使用できます/usr/bin/timex
指定されたコマンドが実行されます。実行に費やされた経過時間、ユーザー時間、およびシステム時間が秒単位で報告されます。オプションで、コマンドとそのすべての子のプロセス アカウンティング データを一覧表示または要約したり、実行間隔中のシステム アクティビティの合計を報告したりできます。
...
-p command とそのすべての子のプロセス アカウンティング レコードを一覧表示します。このオプションは、プロセス アカウンティング ソフトウェアがインストールされている場合にのみ機能します。サブオプション f、h、k、m、r、および t は、報告されるデータ項目を変更します。オプションは次のとおりです。
...
acctadm
プロセス アカウンティングを有効にするには、man ページから始めます。
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#158 (これは実際には OpenSolaris ソースであり、Oracle はサポートを終了しました。ただし、Solaris 11.2 でのいくつかのテストでは、RSS データが実際にはまだゼロであることが示されています。)wait3()
また、Solarisのgetrusage()
マニュアル ページから:
この実装では、構造体の
ru_maxrss
、ru_ixrss
、ru_idrss
、およびru_isrss
メンバーはrusage
0 に設定されます。
など、ほぼ確実にデータを取得する他の方法がありますdtrace
。
編集:
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: failed to compile script memuse.d: line 8: translator does not define conversion for member: pr_pctmem
dtrace
Solaris では、プロセスのメモリ使用量へのアクセスを提供していないようです。実際、データ用の 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を参照)