catch getProcCpu

This commit is contained in:
Doug MacEachern 2005-06-16 21:27:54 +00:00
parent d182f89671
commit a20b334406
1 changed files with 10 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package net.hyperic.sigar.cmd;
import java.util.List;
import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;
import net.hyperic.sigar.SigarProxy;
import net.hyperic.sigar.CpuPerc;
import net.hyperic.sigar.SigarProxyCache;
@ -56,11 +57,16 @@ public class Top {
for (int i=0; i<pids.length; i++) {
long pid = pids[i];
ProcCpu cpu = sigar.getProcCpu(pid);
List info = Ps.getInfo(sigar, pid);
String cpuPerc = "?";
info.add(info.size()-1,
CpuPerc.format(cpu.getPercent()));
List info = Ps.getInfo(sigar, pid);
try {
ProcCpu cpu = sigar.getProcCpu(pid);
cpuPerc = CpuPerc.format(cpu.getPercent());
} catch (SigarException e) {
}
info.add(info.size()-1, cpuPerc);
System.out.println(Ps.join(info));
}