including fqdn/host in output

This commit is contained in:
Doug MacEachern 2004-07-23 17:45:29 +00:00
parent e9b1f1964b
commit 0d40b99a71
1 changed files with 25 additions and 0 deletions

View File

@ -1,8 +1,11 @@
package net.hyperic.sigar.cmd; package net.hyperic.sigar.cmd;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import net.hyperic.sigar.Sigar; import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;
public class Version extends SigarCommandBase { public class Version extends SigarCommandBase {
private static String[] SYS_PROPS = { private static String[] SYS_PROPS = {
@ -28,9 +31,31 @@ public class Version extends SigarCommandBase {
return "Display sigar version"; 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) { public static void printInfo(PrintStream os) {
String fqdn = getFQDN();
String host = getHostName();
os.println("Sigar version=" + Sigar.VERSION_STRING); os.println("Sigar version=" + Sigar.VERSION_STRING);
os.println("Sigar build date=" + Sigar.BUILD_DATE); os.println("Sigar build date=" + Sigar.BUILD_DATE);
os.println("Current fqdn=" + fqdn);
if (!fqdn.equals(host)) {
os.println("Current host=" + host);
}
os.println(""); os.println("");
for (int i=0; i<SYS_PROPS.length; i++) { for (int i=0; i<SYS_PROPS.length; i++) {