make displayTimes optional

This commit is contained in:
Doug MacEachern 2005-05-13 18:06:46 +00:00
parent 4bc5584626
commit dbf28a4397
1 changed files with 10 additions and 2 deletions

View File

@ -9,6 +9,8 @@ import net.hyperic.sigar.SigarException;
*/
public class CpuInfo extends SigarCommandBase {
public boolean displayTimes = true;
public CpuInfo(Shell shell) {
super(shell);
}
@ -25,13 +27,12 @@ public class CpuInfo extends SigarCommandBase {
net.hyperic.sigar.CpuInfo[] infos =
this.sigar.getCpuInfoList();
CpuPerc[] cpus = this.sigar.getCpuPercList();
CpuPerc[] cpus = null;
println(infos.length + " total CPUs..");
for (int i=0; i<infos.length; i++) {
net.hyperic.sigar.CpuInfo info = infos[i];
CpuPerc cpu = cpus[i];
long cacheSize = info.getCacheSize();
println("Vendor........" + info.getVendor());
println("Model........." + info.getModel());
@ -39,6 +40,13 @@ public class CpuInfo extends SigarCommandBase {
if (cacheSize != Sigar.FIELD_NOTIMPL) {
println("Cache size...." + cacheSize);
}
if (!this.displayTimes) {
continue;
}
if (cpus == null) {
cpus = this.sigar.getCpuPercList();
}
CpuPerc cpu = cpus[i];
println("User Time....." + CpuPerc.format(cpu.getUser()));
println("Sys Time......" + CpuPerc.format(cpu.getSys()));
println("Idle Time....." + CpuPerc.format(cpu.getIdle()));