001: /*
002: * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/info/SystemInfo.java,v 1.10 2007/01/15 10:31:14 dungbtm Exp $
003: * $Author: dungbtm $
004: * $Revision: 1.10 $
005: * $Date: 2007/01/15 10:31:14 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding MyVietnam and MyVietnam CoreLib
012: * MUST remain intact in the scripts and source code.
013: *
014: * This library is free software; you can redistribute it and/or
015: * modify it under the terms of the GNU Lesser General Public
016: * License as published by the Free Software Foundation; either
017: * version 2.1 of the License, or (at your option) any later version.
018: *
019: * This library is distributed in the hope that it will be useful,
020: * but WITHOUT ANY WARRANTY; without even the implied warranty of
021: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
022: * Lesser General Public License for more details.
023: *
024: * You should have received a copy of the GNU Lesser General Public
025: * License along with this library; if not, write to the Free Software
026: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
027: *
028: * Correspondence and Marketing Questions can be sent to:
029: * info at MyVietnam net
030: *
031: * @author: Minh Nguyen
032: * @author: Mai Nguyen
033: */
034: package net.myvietnam.mvncore.info;
035:
036: public class SystemInfo {
037:
038: private String vmName;
039: private String vmVendor;
040: private String vmVersion;
041: private String runtimeName;
042: private String runtimeVersion;
043: private String osName;
044: private String osVersion;
045: private String cpu;
046:
047: long totalMemory = 0;
048: long freeMemory = 0;
049: long totalMemoryKB = 0;
050: long freeMemoryKB = 0;
051:
052: public SystemInfo() {
053: vmName = getProperty("java.vm.name");
054: vmVendor = getProperty("java.vm.vendor");
055: vmVersion = getProperty("java.vm.version");
056: runtimeName = getProperty("java.runtime.name");
057: runtimeVersion = getProperty("java.runtime.version");
058: osName = getProperty("os.name");
059: osVersion = getProperty("os.version");
060: cpu = getProperty("sun.cpu.isalist");
061:
062: Runtime runtime = Runtime.getRuntime();
063: totalMemory = runtime.totalMemory();
064: freeMemory = runtime.freeMemory();
065: totalMemoryKB = totalMemory / 1024;
066: freeMemoryKB = freeMemory / 1024;
067: }
068:
069: public static String getProperty(String key) {
070: String retValue = null;
071: try {
072: retValue = System.getProperty(key, "");
073: } catch (Exception ex) {
074: retValue = "no access";
075: }
076: return retValue;
077: }
078:
079: public String getCpu() {
080: return cpu;
081: }
082:
083: public String getOsName() {
084: return osName;
085: }
086:
087: public String getOsVersion() {
088: return osVersion;
089: }
090:
091: public String getRuntimeName() {
092: return runtimeName;
093: }
094:
095: public String getRuntimeVersion() {
096: return runtimeVersion;
097: }
098:
099: public String getVmName() {
100: return vmName;
101: }
102:
103: public String getVmVendor() {
104: return vmVendor;
105: }
106:
107: public String getVmVersion() {
108: return vmVersion;
109: }
110:
111: public long getFreeMemory() {
112: return freeMemory;
113: }
114:
115: public long getFreeMemoryKB() {
116: return freeMemoryKB;
117: }
118:
119: public long getTotalMemory() {
120: return totalMemory;
121: }
122:
123: public long getTotalMemoryKB() {
124: return totalMemoryKB;
125: }
126: }
|