ProcMem for multiple processes

This commit is contained in:
Doug MacEachern 2004-11-10 23:37:57 +00:00
parent 79e50a55ba
commit 54dbe31c62
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package net.hyperic.sigar;
import net.hyperic.sigar.ptql.ProcessFinder;
public class MultiProcMem extends ProcMem {
static ProcMem get(Sigar sigar, String query)
throws SigarException {
ProcMem mem = new ProcMem();
long[] pids = ProcessFinder.find(sigar, query);
for (int i=0; i<pids.length; i++) {
ProcMem pmem = sigar.getProcMem(pids[i]);
mem.size += pmem.size;
mem.vsize += pmem.vsize;
mem.resident += pmem.resident;
mem.share += pmem.share;
mem.rss += pmem.rss;
}
return mem;
}
}