/*
* (C) Copyright 2004 Nabh Information Systems, Inc.
*
* All copyright notices regarding Nabh's products MUST remain
* intact in the scripts and in the outputted HTML.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package com.nabhinc.util.info;
/**
*
*
* @author Padmanabh Dabke
* (c) 2004 Nabh Information Systems, Inc. All Rights Reserved.
*/
public class SystemInfo {
private String siVMName = null;
private String siVMVendor = null;
private String siVMVersion = null;
private String siVMModeInfo = null;
private String siVMSpecName = null;
private String siVMSpecVendor = null;
private String siJavaSpecVersion = null;
private String siRTName = null;
private String siRTVersion = null;
private String siOSName = null;
private String siOSVersion = null;
private String siCPU = null;
private String siByteOrder = null;
private String siTimeZone = null;
private String siDefaultLang = null;
long siTotalMemory = 0;
long siFreeMemory = 0;
public SystemInfo() {
siVMName = getPropertyValue("java.vm.name");
siVMVendor = getPropertyValue("java.vm.vendor");
siVMVersion = getPropertyValue("java.vm.version");
siVMModeInfo = getPropertyValue("java.vm.info");
siVMSpecName = getPropertyValue("java.vm.specification.name");
siVMSpecVendor = getPropertyValue("java.vm.specification.vendor");
siJavaSpecVersion = getPropertyValue("java.specification.version");
siRTName = getPropertyValue("java.runtime.name");
siRTVersion = getPropertyValue("java.runtime.version");
siOSName = getPropertyValue("os.name");
siOSVersion = getPropertyValue("os.version");
siCPU = getPropertyValue("sun.cpu.isalist");
siByteOrder = getPropertyValue("sun.cpu.endian");
siTimeZone = getPropertyValue("user.timezone");
siDefaultLang = getPropertyValue("user.language");
Runtime rt = Runtime.getRuntime();
siTotalMemory = rt.totalMemory();
siFreeMemory = rt.freeMemory();
}
public static String getPropertyValue(String key) {
String propValue = null;
try {
propValue = System.getProperty(key, "");
} catch (NullPointerException ne) {
propValue = "not available";
} catch (IllegalArgumentException ie) {
propValue = "";
}catch (SecurityException ex) {
propValue = "can not be displayed";
}
return propValue;
}
public String getCPUInfo() {
return siCPU;
}
public String getOSName() {
return siOSName;
}
public String getOSVersion() {
return siOSVersion;
}
public String getVMRuntimeName() {
return siRTName;
}
public String getVMRuntimeVersion() {
return siRTVersion;
}
public String getVMName() {
return siVMName;
}
public String getVMVendor() {
return siVMVendor;
}
public String getVMSpecificationName() {
return siVMSpecName;
}
public String getVMSpecificationVendor() {
return siVMSpecVendor;
}
public String getVMVersion() {
return siVMVersion;
}
public String getVMModeInfo() {
return siVMModeInfo;
}
public String getJavaSpecificationVersion() {
return siJavaSpecVersion;
}
public long getFreeMemory() {
return siFreeMemory;
}
public long getFreeMemoryKB() {
return siFreeMemory/1024;
}
public long getFreeMemoryMB() {
return siFreeMemory/(1024 * 1024);
}
public long getTotalMemory() {
return siTotalMemory;
}
public long getTotalMemoryKB() {
return siTotalMemory/1024;
}
public long getTotalMemoryMB() {
return siTotalMemory/(1024 * 1024);
}
public String getEndianInfo() {
return siByteOrder;
}
public String getTimeZone() {
return siTimeZone;
}
public String getDefaultLanguage() {
return siDefaultLang;
}
}
|