From cb332cccdc527e225da90548e6b460be828788da Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 27 Feb 2005 22:29:28 +0000 Subject: [PATCH] use OS class to get linux vendor info --- .../src/net/hyperic/sigar/cmd/SysInfo.java | 56 +++---------------- 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/SysInfo.java b/bindings/java/src/net/hyperic/sigar/cmd/SysInfo.java index 57b37dc7..326970a4 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/SysInfo.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/SysInfo.java @@ -1,13 +1,8 @@ package net.hyperic.sigar.cmd; +import net.hyperic.sigar.OperatingSystem; import net.hyperic.sigar.SigarException; -import java.io.File; -import java.io.FilenameFilter; -import java.io.FileReader; -import java.io.BufferedReader; -import java.io.IOException; - /** * Display System Information */ @@ -37,51 +32,14 @@ public class SysInfo extends SigarCommandBase { /** * OS info */ - this.out.println(osName + " " + - System.getProperty("os.version") + " " + - System.getProperty("os.arch")); + OperatingSystem os = OperatingSystem.getInstance(); + + this.out.println(os.getName() + " " + + os.getVersion() + " " + + os.getArch()); - /** - * craziness to try to determine the linux distro - */ if (osName.equals("Linux")) { - File etc = new File("/etc"); - File[] release = etc.listFiles(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - boolean distroFile = contains(name, "elease"); - - if (!distroFile) { - distroFile = contains(name, "ersion"); - } - return distroFile; - } - }); - - if (release.length != 1) { - this.out.println("Cannot determine Linux distribution!"); - if (release.length > 1) { - this.out.println("Possible version files:"); - for (int i = 0 ; i < release.length ; i++) { - this.out.println(" " + release[i]); - } - } - } - else { - try { - //this.out.println(release[0].getAbsoluteFile() + ":"); - BufferedReader rel = new BufferedReader( - new FileReader(release[0])); - String line; - while ((line = rel.readLine()) != null) { - this.out.println(line); - } - } - catch (IOException e) { - this.out.println("Cannot determine Linux distribution!"); - } - } + println(os.getVendor() + " " + os.getVendorVersion()); } /**