modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
| 10 ++++++++--
modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
| 8 ++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
New commits:
commit 49fe82e497cd3fb258fa29aca8bfebe7c480b14e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 1 13:38:52 2013 -0400
BZ 848258 - trim empty space/newlines from script output prior to applying any regex
filters.
diff --git
a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
index 8cbd84e..c685efe 100644
---
a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
+++
b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
@@ -31,11 +31,11 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -125,6 +125,9 @@ public class ScriptDiscoveryComponent implements
ResourceDiscoveryComponent, Man
} else if (results.getCapturedOutput() != null) {
String regex =
pluginConfig.getSimpleValue(ScriptServerComponent.PLUGINCONFIG_DESC_REGEX, null);
String output = results.getCapturedOutput();
+ if (output != null) {
+ output = output.trim();
+ }
if (regex == null) {
description = output;
} else {
@@ -176,6 +179,9 @@ public class ScriptDiscoveryComponent implements
ResourceDiscoveryComponent, Man
String regex =
pluginConfig.getSimpleValue(ScriptServerComponent.PLUGINCONFIG_VERSION_REGEX,
null);
String output = results.getCapturedOutput();
+ if (output != null) {
+ output = output.trim();
+ }
if (regex == null) {
version = output;
} else {
diff --git
a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
index 0ff12b0..c964c69 100644
---
a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
+++
b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
@@ -184,11 +184,13 @@ public class ScriptServerComponent implements ResourceComponent,
MeasurementFace
continue;
}
} else if (regex != null) {
- final String output = exeResults.getCapturedOutput();
+ String output = exeResults.getCapturedOutput();
if (output == null) {
log.error("Could not get output for metric property ["
+ metricPropertyName
+ "] -- metric will not be collected");
continue;
+ } else {
+ output = output.trim();
}
Pattern pattern = Pattern.compile(regex);
@@ -336,7 +338,7 @@ public class ScriptServerComponent implements ResourceComponent,
MeasurementFace
resultsConfig.put(new PropertySimple(OPERATION_RESULT_EXITCODE, exitcode));
}
if (output != null) {
- resultsConfig.put(new PropertySimple(OPERATION_RESULT_OUTPUT, output));
+ resultsConfig.put(new PropertySimple(OPERATION_RESULT_OUTPUT,
output.trim()));
}
return result;
@@ -498,6 +500,8 @@ public class ScriptServerComponent implements ResourceComponent,
MeasurementFace
String output = results.getCapturedOutput();
if (output == null) {
output = "";
+ } else {
+ output = output.trim();
}
boolean outputMatches = output.matches(availOutputRegex);
Show replies by date