我已经下载了 Sigar API(http://support.hyperic.com/display/SIGAR/Home http://support.hyperic.com/display/SIGAR/Home)并希望在项目中使用它来获取有关正在运行的不同进程的信息。
我的问题是,我无法真正找到一些有用的代码片段来学习,而且他们网站上的 javadoc 也没有多大帮助,因为我不知道我应该寻找什么。
您知道我可以在哪里找到更多信息吗?
为了找到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
Where:
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 http://support.hyperic.com/display/SIGAR/PTQL
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)