5

Sigar API(http://support.hyperic.com/display/SIGAR/Home)をダウンロードしました。これをプロジェクトで使用して、実行中のさまざまなプロセスに関する情報を取得したいと思います。

私の問題は、学ぶのに役立つコードスニペットが実際に見つからず、何を探すべきかわからないため、Webサイトのjavadocがあまり役に立たないことです。

もっと情報を見つけられるアイデアはありますか?

4

4 に答える 4

11

pid(特定のプロセスに関する情報を見つけるために必要な) を見つけるには、 を使用できますProcessFinder。単一のプロセス pid を見つける方法はfindSingleProcess(String expression). 例:

    Sigar sigar=new Sigar();
    ProcessFinder find=new ProcessFinder(sigar);
    long pid=find.findSingleProcess("Exe.Name.ct=explorer");
    ProcMem memory=new ProcMem();
    memory.gather(sigar, pid);
    System.out.println(Long.toString(memory.getSize()));

式の構文は次のとおりです。

Class.Attribute.operator=value

どこ:

Class is the name of the Sigar class minus the Proc prefix.
Attribute is an attribute of the given Class, index into an array or key in a Map class.
operator is one of the following for String values:
eq - Equal to value
ne - Not Equal to value
ew - Ends with value
sw - Starts with value
ct - Contains value (substring)
re - Regular expression value matches
operator is one of the following for numeric values:
eq - Equal to value
ne - Not Equal to value
gt - Greater than value
ge - Greater than or equal value
lt - Less than value
le - Less than or equal value

詳細はこちら: http://support.hyperic.com/display/SIGAR/PTQL

于 2012-09-21T09:51:46.363 に答える
2

Windows 7を使用している場合は、何かを試してください

likefindSingleProcess("State.Name.ct=explorer");
于 2014-03-19T14:26:33.287 に答える
0

最新のパッケージでは、下に多くの使用例が示されてbindings\java\examplesいます。それらをチェックしてください。

于 2013-10-11T07:35:50.830 に答える