From: <do...@hy...> - 2009-04-09 06:28:13
|
Author: dougm Date: 2009-04-08 23:28:07 -0700 (Wed, 08 Apr 2009) New Revision: 12967 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=12967 Modified: branches/HQ_3_2/plugins/netservices/src/org/hyperic/hq/plugin/netservices/NetServicesCollector.java branches/HQ_3_2/src/org/hyperic/hq/product/GenericPlugin.java branches/HQ_3_2/src/org/hyperic/hq/product/ServerDetector.java Log: [HHQ-2915] disable ServerDetector.getListenAddress if netservices.netstat=false (merged r12887 from trunk) Modified: branches/HQ_3_2/plugins/netservices/src/org/hyperic/hq/plugin/netservices/NetServicesCollector.java =================================================================== --- branches/HQ_3_2/plugins/netservices/src/org/hyperic/hq/plugin/netservices/NetServicesCollector.java 2009-04-08 21:06:12 UTC (rev 12966) +++ branches/HQ_3_2/plugins/netservices/src/org/hyperic/hq/plugin/netservices/NetServicesCollector.java 2009-04-09 06:28:07 UTC (rev 12967) @@ -46,8 +46,6 @@ public abstract class NetServicesCollector extends Collector { - private static final String PROP_NETSTAT = "netservices.netstat"; - private int port = -1; private int defaultPort, defaultSSLPort; private boolean isSSL, enableNetstat; @@ -101,8 +99,7 @@ protected void init() throws PluginException { Properties props = getProperties(); - this.enableNetstat = - !"false".equals(getPlugin().getManagerProperty(PROP_NETSTAT)); + this.enableNetstat = getPlugin().isNetStatEnabled(); if (this.enableNetstat) { if (sigar == null) { sigar = new Sigar(); Modified: branches/HQ_3_2/src/org/hyperic/hq/product/GenericPlugin.java =================================================================== --- branches/HQ_3_2/src/org/hyperic/hq/product/GenericPlugin.java 2009-04-08 21:06:12 UTC (rev 12966) +++ branches/HQ_3_2/src/org/hyperic/hq/product/GenericPlugin.java 2009-04-09 06:28:07 UTC (rev 12967) @@ -53,6 +53,7 @@ import org.apache.commons.logging.LogFactory; public abstract class GenericPlugin { + private static final String PROP_NETSTAT = "netservices.netstat"; /** * Key used to store value of XML resource name attribute. @@ -137,7 +138,11 @@ return absoluteFiles; } - + + public boolean isNetStatEnabled() { + return !"false".equals(getManagerProperty(PROP_NETSTAT)); + } + /** * @return true if the current platform is in the Windows family. */ Modified: branches/HQ_3_2/src/org/hyperic/hq/product/ServerDetector.java =================================================================== --- branches/HQ_3_2/src/org/hyperic/hq/product/ServerDetector.java 2009-04-08 21:06:12 UTC (rev 12966) +++ branches/HQ_3_2/src/org/hyperic/hq/product/ServerDetector.java 2009-04-09 06:28:07 UTC (rev 12967) @@ -631,21 +631,30 @@ protected String getListenAddress(long port) { String address = null; - try { - address = - getSigar().getNetListenAddress(port); - } catch (SigarException e) { + if (isNetStatEnabled()) { + try { + address = + getSigar().getNetListenAddress(port); + } catch (SigarException e) {} } + else { + getLog().debug("ListenAddress detection for port " + port + " is disabled"); + } + String type; if ((address == null) || NetFlags.isLoopback(address) || NetFlags.isAnyAddress(address)) { address = "localhost"; + type = "default"; } + else { + type = "discovered"; + } + getLog().debug("ListenAddress for port " + port + "=" + address + + " (" + type + ")"); - getLog().debug("ListenAddress for port " + port + "=" + address); - return address; } |