适用于JAVA的Sigar API(需要指南) [英] Sigar API for JAVA (need a guide)

查看:1579
本文介绍了适用于JAVA的Sigar API(需要指南)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已下载Sigar API( http://support.hyperic.com/display/SIGAR/Home)并希望在项目中使用它来获取有关正在运行的不同进程的信息。

I've downloaded Sigar API ( http://support.hyperic.com/display/SIGAR/Home ) and would like to use it in a project to get information about different processes which are running.

我的问题是我找不到一些有用的代码片段学习和从他们的网站javadoc没有多大帮助,因为我不知道我应该寻找什么。

My problem is that I can't really find some useful code snippets to learn from and the javadoc from their website isn't of much help, because I don't know what I should be looking for.

你有任何想法吗?我可以找到更多信息吗?

Do you have any ideea where I could find more information?

推荐答案

查找 pid (其中需要查找有关某个过程的信息),您可以使用 ProcessFinder
查找单个进程pid的方法是 findSingleProcess(String expression)。示例:

To find the pid (which is needed to find out information about a certain process), you can use a ProcessFinder. The method to find a single process pid is findSingleProcess(String expression). Example:

    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

这篇关于适用于JAVA的Sigar API(需要指南)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆