package net.hyperic.sigar.cmd;

import net.hyperic.sigar.CpuPerc;
import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;

/**
 * Display cpu information for each cpu found on the system.
 */
public class CpuInfo extends SigarCommandBase {

    public CpuInfo(Shell shell) {
        super(shell);
    }

    public CpuInfo() {
        super();
    }

    public String getUsageShort() {
        return "Display cpu information";
    }

    public void output(String[] args) throws SigarException {
        net.hyperic.sigar.CpuInfo[] infos =
            this.sigar.getCpuInfoList();

        CpuPerc[] cpus = this.sigar.getCpuPercList();

        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());
            println("Mhz..........." + info.getMhz());
            if (cacheSize != Sigar.FIELD_NOTIMPL) {
                println("Cache size...." + cacheSize);
            }
            println("User Time....." + CpuPerc.format(cpu.getUser()));
            println("Sys Time......" + CpuPerc.format(cpu.getSys()));
            println("Idle Time....." + CpuPerc.format(cpu.getIdle()));
            println("Wait Time....." + CpuPerc.format(cpu.getWait()));
            println("Nice Time....." + CpuPerc.format(cpu.getNice()));
            println("Combined......" + CpuPerc.format(cpu.getCombined()));
            
            println("");
        }
    }

    public static void main(String[] args) throws Exception {
        new CpuInfo().processCommand(args);
    }
}

@@ -251,16 +251,61 @@
 Base %7B%0A%0A
+    public boolean displayTimes = true;%0A    %0A
     publ
@@ -326,24 +326,24 @@
 ll shell) %7B%0A
-
         supe
@@ -668,35 +668,12 @@
 s = 
-this.sigar.getCpuPercList()
+null
 ;%0A%0A 
@@ -825,43 +825,8 @@
 i%5D;%0A
-            CpuPerc cpu = cpus%5Bi%5D;%0A
     
@@ -1148,16 +1148,16 @@
 eSize);%0A
-
         
@@ -1158,24 +1158,235 @@
           %7D%0A
+            if (!this.displayTimes) %7B%0A                continue;%0A            %7D%0A            if (cpus == null) %7B%0A                cpus = this.sigar.getCpuPercList();%0A            %7D%0A            CpuPerc cpu = cpus%5Bi%5D;%0A
             

make displayTimes optional