001: /*
002: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.sysinfo;
005:
006: import java.io.File;
007: import java.io.FileOutputStream;
008: import java.io.IOException;
009: import java.text.DateFormat;
010: import java.util.Date;
011:
012: public final class EnvStats {
013:
014: public static final String filename = "tc-envstats.txt";
015:
016: public static void writeReport(File directory) throws IOException,
017: IllegalArgumentException {
018: if (!directory.isDirectory())
019: throw new IllegalArgumentException(directory
020: + " is not a directory");
021: FileOutputStream out = new FileOutputStream(directory
022: + File.separator + filename);
023: out.write(report().getBytes());
024: out.flush();
025: out.close();
026: }
027:
028: public static String report() {
029: StringBuffer sb = new StringBuffer();
030: sb
031: .append("***** Terracotta System Environment Report *****\n\n");
032: sb.append("Date Created: "
033: + DateFormat.getDateTimeInstance().format(
034: new Date(System.currentTimeMillis())) + "\n\n");
035: sb.append("java.runtime.name="
036: + System.getProperty("java.runtime.name") + "\n");
037: sb.append("java.vm.version="
038: + System.getProperty("java.vm.version") + "\n");
039: sb.append("java.vm.vendor="
040: + System.getProperty("java.vm.vendor") + "\n");
041: sb.append("java.vendor.url="
042: + System.getProperty("java.vendor.url") + "\n");
043: sb.append("java.vm.name=" + System.getProperty("java.vm.name")
044: + "\n");
045: sb.append("file.encoding.pkg="
046: + System.getProperty("file.encoding.pkg") + "\n");
047: sb.append("user.country=" + System.getProperty("user.country")
048: + "\n");
049: sb.append("sun.os.patch.level="
050: + System.getProperty("sun.os.patch.level") + "\n");
051: sb.append("java.vm.specification.name="
052: + System.getProperty("java.vm.specification.name")
053: + "\n");
054: sb.append("java.runtime.version="
055: + System.getProperty("java.runtime.version") + "\n");
056: sb.append("java.awt.graphicsenv="
057: + System.getProperty("java.awt.graphicsenv") + "\n");
058: sb.append("os.arch=" + System.getProperty("os.arch") + "\n");
059: sb.append("java.vm.specification.vendor="
060: + System.getProperty("java.vm.specification.vendor")
061: + "\n");
062: sb.append("os.name=" + System.getProperty("os.name") + "\n");
063: sb.append("java.library.path="
064: + System.getProperty("java.library.path") + "\n");
065: sb.append("java.specification.name="
066: + System.getProperty("java.specification.name") + "\n");
067: sb.append("java.class.version="
068: + System.getProperty("java.class.version") + "\n");
069: sb
070: .append("java.util.prefs.PreferencesFactory="
071: + System
072: .getProperty("java.util.prefs.PreferencesFactory")
073: + "\n");
074: sb.append("os.version=" + System.getProperty("os.version")
075: + "\n");
076: sb.append("user.timezone="
077: + System.getProperty("user.timezone") + "\n");
078: sb.append("java.awt.printerjob="
079: + System.getProperty("java.awt.printerjob") + "\n");
080: sb.append("file.encoding="
081: + System.getProperty("file.encoding") + "\n");
082: sb.append("java.specification.version="
083: + System.getProperty("java.specification.version")
084: + "\n");
085: sb.append("java.class.path="
086: + System.getProperty("java.class.path") + "\n");
087: sb.append("java.vm.specification.version="
088: + System.getProperty("java.vm.specification.version")
089: + "\n");
090: sb.append("sun.arch.data.model="
091: + System.getProperty("sun.arch.data.model") + "\n");
092: sb
093: .append("java.home=" + System.getProperty("java.home")
094: + "\n");
095: sb.append("java.specification.vendor="
096: + System.getProperty("java.specification.vendor")
097: + "\n");
098: sb.append("user.language="
099: + System.getProperty("user.language") + "\n");
100: sb.append("java.vm.info=" + System.getProperty("java.vm.info")
101: + "\n");
102: sb.append("java.version=" + System.getProperty("java.version")
103: + "\n");
104: sb.append("java.ext.dirs="
105: + System.getProperty("java.ext.dirs") + "\n");
106: sb.append("sun.boot.class.path="
107: + System.getProperty("sun.boot.class.path") + "\n");
108: sb.append("java.vendor=" + System.getProperty("java.vendor")
109: + "\n");
110: sb.append("java.vendor.url.bug="
111: + System.getProperty("java.vendor.url.bug") + "\n");
112: sb.append("sun.cpu.endian="
113: + System.getProperty("sun.cpu.endian") + "\n");
114: sb.append("sun.io.unicode.encoding="
115: + System.getProperty("sun.io.unicode.encoding") + "\n");
116: sb.append("sun.cpu.isalist="
117: + System.getProperty("sun.cpu.isalist") + "\n");
118: return sb.toString();
119: }
120: }
|