modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
| 27 ++++++++--
modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
| 5 +
2 files changed, 25 insertions(+), 7 deletions(-)
New commits:
commit be3cc52bd5d5a0651f1029db4cebe20c42b0bddd
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue May 31 16:36:54 2011 +0200
BZ 709369 - The vhost URL is now optional and availability can be checked by pinging
the SNMP location
diff --git
a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index 63d5dbf..922f943 100644
---
a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++
b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -19,18 +19,16 @@
package org.rhq.plugins.apache;
import java.io.File;
-import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.UnknownHostException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.augeas.node.AugeasNode;
import org.rhq.augeas.tree.AugeasTree;
import org.rhq.core.domain.configuration.Configuration;
@@ -60,7 +58,6 @@ import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
import org.rhq.plugins.apache.util.AugeasNodeSearch;
import org.rhq.plugins.apache.util.AugeasNodeValueUtil;
import org.rhq.plugins.apache.util.ConfigurationTimestamp;
-import org.rhq.plugins.apache.util.HttpdAddressUtility;
import org.rhq.plugins.apache.util.RuntimeApacheConfiguration;
import org.rhq.plugins.www.snmp.SNMPException;
import org.rhq.plugins.www.snmp.SNMPSession;
@@ -132,7 +129,27 @@ public class ApacheVirtualHostServiceComponent implements
ResourceComponent<Apac
}
public AvailabilityType getAvailability() {
- return (this.url != null && WWWUtils.isAvailable(this.url)) ?
AvailabilityType.UP : AvailabilityType.DOWN;
+ if (url != null) {
+ return WWWUtils.isAvailable(url) ? AvailabilityType.UP :
AvailabilityType.DOWN;
+ } else {
+ try {
+ //we don't need the SNMP connection to figure out the index on which
the SNMP
+ //module would report this vhost. So first, let's check if that index
is valid
+ //(i.e. check that the vhost is actually still present in the apache
configuration)
+ if (getWwwServiceIndex() < 1) {
+ return AvailabilityType.DOWN;
+ }
+
+ //ok, so the vhost is present. Now let's just ping the SNMP module to
see
+ //if it is reachable and base our availability on that...
+ SNMPSession snmpSession =
resourceContext.getParentResourceComponent().getSNMPSession();
+
+ return snmpSession.ping() ? AvailabilityType.UP : AvailabilityType.DOWN;
+ } catch (Exception e) {
+ log.debug("Determining the availability of the vhost [" +
resourceContext.getResourceKey() + "] using SNMP failed.", e);
+ return AvailabilityType.DOWN;
+ }
+ }
}
public Configuration loadResourceConfiguration() throws Exception {
diff --git a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
index b80a3f3..f3cf33f 100644
--- a/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/apache/src/main/resources/META-INF/rhq-plugin.xml
@@ -513,10 +513,11 @@
<service name="Apache Virtual Host"
discovery="ApacheVirtualHostServiceDiscoveryComponent"
class="ApacheVirtualHostServiceComponent"
createDeletePolicy="both">
<plugin-configuration>
- <c:simple-property name="url" displayName="URL"
+ <c:simple-property name="url" displayName="URL"
required="false"
description="The http or https URL that will be used
to check availability for this
virtual host. Note that SSL certificate validation is
disabled during availability
- checks if this is an HTTPS URL."/>
+ checks if this is an HTTPS URL. If the URL is not set,
the availability is determined
+ by pinging the configured SNMP location."/>
<c:group name="ResponseTime">
<c:simple-property name="responseTimeLogFile"
required="false"
description="the full path to the log file
containing response-time stats for this virtual host"/>
Show replies by date