diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Version.java b/bindings/java/src/net/hyperic/sigar/cmd/Version.java index 91ae6a89..f610ee91 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Version.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Version.java @@ -1,8 +1,11 @@ package net.hyperic.sigar.cmd; import java.io.PrintStream; +import java.net.InetAddress; +import java.net.UnknownHostException; import net.hyperic.sigar.Sigar; +import net.hyperic.sigar.SigarException; public class Version extends SigarCommandBase { private static String[] SYS_PROPS = { @@ -28,9 +31,31 @@ public class Version extends SigarCommandBase { return "Display sigar version"; } + private static String getHostName() { + try { + return InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + return "unknown"; + } + } + + private static String getFQDN() { + try { + return Sigar.getInstance().getFQDN(); + } catch (SigarException e) { + return "unknown"; + } + } + public static void printInfo(PrintStream os) { + String fqdn = getFQDN(); + String host = getHostName(); os.println("Sigar version=" + Sigar.VERSION_STRING); os.println("Sigar build date=" + Sigar.BUILD_DATE); + os.println("Current fqdn=" + fqdn); + if (!fqdn.equals(host)) { + os.println("Current host=" + host); + } os.println(""); for (int i=0; i