我已经下载了Sigar API ( http://support.hyperic.com/display/SIGAR/Home ),并想在一个项目中使用它来获取有关正在运行的不同进程的信息。
我的问题是,我真的找不到一些有用的代码片段来学习,他们网站上的javadoc也没有多大帮助,因为我不知道我应该寻找什么。
你有什么想法可以让我找到更多的信息吗?
发布于 2012-09-21 17:51:46
要查找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
发布于 2014-03-19 22:26:33
如果您使用的是Windows 7,请尝试执行以下操作
likefindSingleProcess("State.Name.ct=explorer");发布于 2013-10-11 15:35:51
在他们最新的软件包中,他们给出了很多在bindings\java\examples下的用法示例。看看他们。
https://stackoverflow.com/questions/12511956
复制相似问题