From 4152a45f7afdea56b49b5e66952497731fc8919c Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 26 Feb 2005 02:03:11 +0000 Subject: [PATCH] starting class to get more os/vendor specific info --- .../net/hyperic/sigar/OperatingSystem.java | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 bindings/java/src/net/hyperic/sigar/OperatingSystem.java diff --git a/bindings/java/src/net/hyperic/sigar/OperatingSystem.java b/bindings/java/src/net/hyperic/sigar/OperatingSystem.java new file mode 100644 index 00000000..85e8fcdc --- /dev/null +++ b/bindings/java/src/net/hyperic/sigar/OperatingSystem.java @@ -0,0 +1,165 @@ +package net.hyperic.sigar; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.File; +import java.io.FileReader; + +import java.util.Properties; +import java.util.StringTokenizer; + +public class OperatingSystem { + + private static final String ETC = + System.getProperty("sigar.etc.dir", "/etc") + "/"; + + private String name; + private String version; + private String arch; + private String patchLevel; + private String vendor; + private String vendorVersion; + + private OperatingSystem() { + } + + public static OperatingSystem getInstance() { + OperatingSystem os = new OperatingSystem(); + Properties props = System.getProperties(); + os.name = props.getProperty("os.name"); + os.version = props.getProperty("os.version"); + os.arch = props.getProperty("os.arch"); + os.patchLevel = props.getProperty("sun.os.patch.level"); + + if (os.name.equals("Linux")) { + os.getLinuxInfo(); + } + + return os; + } + + public String getName() { + return this.name; + } + + public String getVersion() { + return this.version; + } + + public String getArch() { + return this.arch; + } + + public String getPatchLevel() { + return this.patchLevel; + } + + public String getVendor() { + return this.vendor; + } + + public String getVendorVersion() { + return this.vendorVersion; + } + + private void getLinuxInfo() { + VendorInfo[] info = { + new GenericVendor("mandrake-release", "Mandrake"), + new GenericVendor("SuSE-release", "SuSE"), + new GenericVendor("gentoo-release", "Gentoo"), + new GenericVendor("debian_version", "Debian"), + new GenericVendor("slackware-version", "Slackware"), + new GenericVendor("fedora-release", "Fedora"), + new RedHatVendor("redhat-release", "Red Hat"), + }; + + for (int i=0; i