package net.hyperic.sigar.cmd;

import net.hyperic.sigar.CpuInfo;
import net.hyperic.sigar.OperatingSystem;
import net.hyperic.sigar.SigarException;

/**
 * Display System Information
 */
public class SysInfo extends SigarCommandBase {

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

    public SysInfo() {
        super();
    }

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

    private String getJavaProp(String name) {
        return System.getProperty("java." + name);
    }

    public void output(String[] args) throws SigarException {
        /**
         * OS info
         */
        OperatingSystem os = OperatingSystem.getInstance();

        println(os.getName() + " " +
                os.getVersion() + " " +
                os.getArch());

        if (os.getName().equals("Linux")) {
            println(os.getVendor() + " " + os.getVendorVersion());
        }

        /**
         * JVM info
         */
        println(getJavaProp("vm.name") + " - " +
                getJavaProp("vm.vendor") + " [" +
                getJavaProp("vm.version") + "]");

        println(getJavaProp("specification.vendor") + " " +
                getJavaProp("specification.name") + " " +
                getJavaProp("specification.version"));
        println("JAVA_HOME=" + getJavaProp("home"));
        println("");

        /**
         * uptime
         */
        new Uptime(this.shell).output(args);
        println("");

        /**
         * CPU info
         */
        CpuInfo[] infos = this.sigar.getCpuInfoList();
        for (int i=0; i<infos.length; i++) {
            CpuInfo info = infos[i];
            println("CPU " + i + ":");
            println("  Vendor........" + info.getVendor());
            println("  Model........." + info.getModel());
            println("  Mhz..........." + info.getMhz());
            println("  Cache size...." + info.getCacheSize());
        }
        println("");

        /**
         * memory info
         */
        new Free(this.shell).output(args);
    }

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

@@ -29,84 +29,8 @@
 d;%0A%0A
-import net.hyperic.sigar.CpuInfo;%0Aimport net.hyperic.sigar.OperatingSystem;%0A
 impo
@@ -361,921 +361,123 @@
    p
-rivate String getJavaProp(String name) %7B%0A        return System.getProperty(%22java.%22 + name);%0A    %7D%0A%0A    public void output(String%5B%5D args) throws SigarException %7B%0A        /**%0A         * OS info%0A         */%0A        OperatingSystem os = OperatingSystem.getInstance();%0A%0A        println(os.getName() + %22 %22 +%0A                os.getVersion() + %22 %22 +%0A                os.getArch());%0A%0A        if (os.getName().equals(%22Linux%22)) %7B%0A            println(os.getVendor() + %22 %22 + os.getVendorVersion());%0A        %7D%0A%0A        /**%0A         * JVM info%0A         */%0A        println(getJavaProp(%22vm.name%22) + %22 - %22 +%0A                getJavaProp(%22vm.vendor%22) + %22 %5B%22 +%0A                getJavaProp(%22vm.version%22) + %22%5D%22);%0A%0A        println(getJavaProp(%22specification.vendor%22) + %22 %22 +%0A                getJavaProp(%22specification.name%22) + %22 %22 +%0A                getJavaProp(%22specification.version%22));%0A        println(%22JAVA_HOME=%22 + getJavaProp(%22home%22)
+ublic void output(String%5B%5D args) throws SigarException %7B%0A        //sigar/os info%0A        Version.printInfo(this.out
 );%0A 
@@ -510,41 +510,16 @@
    /
-**%0A         * 
+/
 uptime%0A
-         */%0A
     
@@ -594,43 +594,18 @@
    /
-**%0A         * CPU
+/cpu
  info%0A
-         */%0A
     
@@ -619,486 +619,155 @@
 Info
-%5B%5D 
+ cpu
 info
-s
  = 
-this.sigar.getCpuInfoList();%0A        for (int i=0; i%3Cinfos.length; i++) %7B%0A            CpuInfo info = infos%5Bi%5D;%0A            println(%22CPU %22 + i + %22:%22);%0A            println(%22  Vendor........%22 + info.getVendor());%0A            println(%22  Model.........%22 + info.getModel());%0A            println(%22  Mhz...........%22 + info.getMhz());%0A            println(%22  Cache size....%22 + info.getCacheSize());%0A        %7D%0A        println(%22%22);%0A%0A        /**%0A         * memory info%0A         */
+new CpuInfo(this.shell);%0A        cpuinfo.displayTimes = false;%0A        cpuinfo.output(args);%0A        println(%22%22);%0A%0A        //memory info
 %0A   

use shell commands