}
public static void main(String[] args) throws Exception {
Sigar sigarImpl = new Sigar();
SigarProxy sigar =
SigarProxyCache.newInstance(sigarImpl, SLEEP_TIME);
while (true) {
Shell.clearScreen();
System.out.println(Uptime.getInfo(sigar));
System.out.println(toString(sigar.getProcStat()));
System.out.println(sigar.getCpuPerc());
System.out.println(sigar.getMem());
System.out.println(sigar.getSwap());
System.out.println();
System.out.println(HEADER);
long[] pids = Shell.getPids(sigar, args);
for (int i=0; i<pids.length; i++) {
long pid = pids[i];
String cpuPerc = "?";
List info;
try {
info = Ps.getInfo(sigar, pid);
} catch (SigarException e) {
continue; //process may have gone away
}
try {
ProcCpu cpu = sigar.getProcCpu(pid);
cpuPerc = CpuPerc.format(cpu.getPercent());
} catch (SigarException e) {
}
info.add(info.size()-1, cpuPerc);