From 0d40b99a71d16edf3e80331995bd978723149451 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 23 Jul 2004 17:45:29 +0000 Subject: [PATCH] including fqdn/host in output --- .../src/net/hyperic/sigar/cmd/Version.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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