some cleanup

This commit is contained in:
Doug MacEachern 2005-02-27 22:42:05 +00:00
parent cb332cccdc
commit 69158c8553
1 changed files with 25 additions and 28 deletions

View File

@ -1,5 +1,6 @@
package net.hyperic.sigar.cmd; package net.hyperic.sigar.cmd;
import net.hyperic.sigar.CpuInfo;
import net.hyperic.sigar.OperatingSystem; import net.hyperic.sigar.OperatingSystem;
import net.hyperic.sigar.SigarException; import net.hyperic.sigar.SigarException;
@ -20,60 +21,56 @@ public class SysInfo extends SigarCommandBase {
return "Display system information"; return "Display system information";
} }
private static boolean contains(String value, String substr) { private String getJavaProp(String name) {
//matches does not work w/ jre 1.3 return System.getProperty("java." + name);
//value.toLowerCase().matches(".*" + substr + ".*");
return value.toLowerCase().indexOf(substr) != -1;
} }
public void output(String[] args) throws SigarException { public void output(String[] args) throws SigarException {
String osName = System.getProperty("os.name");
/** /**
* OS info * OS info
*/ */
OperatingSystem os = OperatingSystem.getInstance(); OperatingSystem os = OperatingSystem.getInstance();
this.out.println(os.getName() + " " + println(os.getName() + " " +
os.getVersion() + " " + os.getVersion() + " " +
os.getArch()); os.getArch());
if (osName.equals("Linux")) { if (os.getName().equals("Linux")) {
println(os.getVendor() + " " + os.getVendorVersion()); println(os.getVendor() + " " + os.getVendorVersion());
} }
/** /**
* JVM info * JVM info
*/ */
this.out.println(System.getProperty("java.vm.name") + " - " + println(getJavaProp("vm.name") + " - " +
System.getProperty("java.vm.vendor") + " [" + getJavaProp("vm.vendor") + " [" +
System.getProperty("java.vm.version") + "]"); getJavaProp("vm.version") + "]");
this.out.println(System.getProperty("java.specification.vendor") + " " +
System.getProperty("java.specification.name") + " " + println(getJavaProp("specification.vendor") + " " +
System.getProperty("java.specification.version")); getJavaProp("specification.name") + " " +
this.out.println("JAVA_HOME=" + System.getProperty("java.home")); getJavaProp("specification.version"));
this.out.println(""); println("JAVA_HOME=" + getJavaProp("home"));
println("");
/** /**
* uptime * uptime
*/ */
new Uptime(this.shell).output(args); new Uptime(this.shell).output(args);
this.out.println(""); println("");
/** /**
* CPU info * CPU info
*/ */
net.hyperic.sigar.CpuInfo[] infos = CpuInfo[] infos = this.sigar.getCpuInfoList();
this.sigar.getCpuInfoList();
for (int i=0; i<infos.length; i++) { for (int i=0; i<infos.length; i++) {
net.hyperic.sigar.CpuInfo info = infos[i]; CpuInfo info = infos[i];
this.out.println("CPU " + i + ":"); println("CPU " + i + ":");
this.out.println(" Vendor........" + info.getVendor()); println(" Vendor........" + info.getVendor());
this.out.println(" Model........." + info.getModel()); println(" Model........." + info.getModel());
this.out.println(" Mhz..........." + info.getMhz()); println(" Mhz..........." + info.getMhz());
this.out.println(" Cache size...." + info.getCacheSize()); println(" Cache size...." + info.getCacheSize());
} }
this.out.println(""); println("");
/** /**
* memory info * memory info