Sigar API for JAVA (manual required)

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

My problem is that I really can’t find useful snippets of code to find out, and javadoc from my site doesn’t help much, because I don’t know what I need to look for.

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

+5
source share
3 answers

To find pid(which is necessary to obtain information about a specific process), you can use ProcessFinder. The method for finding a single pid process is equal 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

+8

Windows 7, -

likefindSingleProcess("State.Name.ct=explorer");
+1

In their last package, they provide many examples of use in bindings\java\examples. Check them out.

0
source

All Articles