package net.hyperic.sigar.cmd;

import net.hyperic.sigar.CpuPerc;
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];
            println("Vendor........" + info.getVendor());
            println("Model........." + info.getModel());
            println("Mhz..........." + info.getMhz());
            println("Cache size...." + info.getCacheSize());
            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("");
        }
    }

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

@@ -59,16 +59,48 @@
 puPerc;%0A
+import net.hyperic.sigar.Sigar;%0A
 import n
@@ -830,24 +830,74 @@
  = cpus%5Bi%5D;%0A
+            long cacheSize = info.getCacheSize();%0A
             
@@ -1050,24 +1050,80 @@
 .getMhz());%0A
+            if (cacheSize != Sigar.FIELD_NOTIMPL) %7B%0A    
             
@@ -1153,29 +1153,33 @@
 %22 + 
-info.getCacheSize());
+cacheSize);%0A            %7D
 %0A   

check if CacheSize is valid