From 3a3efbd01617be7b586a4e233854dccee7612746 Mon Sep 17 00:00:00 2001 From: Jean-Frederic Clere Date: Thu, 21 Aug 2014 16:33:36 +0200 Subject: [PATCH] Finish fixing mod_bmx support. --- .../plugins/apache/ApacheServerComponent.java | 42 ++++++++++++++++--- .../ApacheVirtualHostServiceComponent.java | 2 + 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java index df392d63ba0..3fb0df0f2f6 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerComponent.java @@ -494,13 +494,18 @@ private void getBMXValues(MeasurementReport report, Set parseBMXInput(String vHost) throws Exception { // If the section does not match our vhost, ignore it. - // TODO the vHost of RHQ needs to be ajusted to the BMX ones. - if (vHost == null) - vHost = "_GLOBAL_"; - if (!line.contains("Host="+vHost)) - continue; + // RHQ will do 3 kinds of vHost: + // null = Guessing Host=_GLOBAL_ + // MainServer = ignore the Host and use Port=_ANY_ + // |*:6666 = ignore the Host and use Port=6666 + // neo4|*:7777 = Use the Host and ignore the Port. + if (vHost == null) { + if (!line.contains("Host=_GLOBAL_,")) + continue; + } else if (vHost.startsWith("|")) { + if (line.contains("Host=_GLOBAL_,")) + continue; + String port = vHost.substring(vHost.indexOf(':')+1); + if (!line.endsWith("Port=" + port)) + continue; + } else if (vHost.equals("MainServer")) { + if (line.contains("Host=_GLOBAL_,")) + continue; + if (!line.endsWith("Port=_ANY_")) + continue; + } else { + if (line.contains("Host=_GLOBAL_,")) + continue; + String host = vHost.substring(0,vHost.indexOf('|')); + if (!line.contains("Host=" + host + ",")) + continue; + } // Now some global data Matcher m = typePattern.matcher(line); @@ -568,6 +596,8 @@ public static Map parseBMXInput(String vHost) throws Exception { slurpSection(ret, reader, type); } + if (line.contains("Type=info,")) + break; // We are done with the VirtualHost. } in.close(); 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 739ac603b8c..cae8d4498a6 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 @@ -416,6 +416,8 @@ private void getBMXValues(MeasurementReport report, Set