[ 
https://issues.apache.org/jira/browse/KARAF-5864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16606823#comment-16606823
 ] 

ASF GitHub Bot commented on KARAF-5864:
---------------------------------------

fpapon closed pull request #51: [KARAF-5864] Add triming on the system 
collector command output
URL: https://github.com/apache/karaf-decanter/pull/51
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/collector/system/src/main/cfg/org.apache.karaf.decanter.collector.system.cfg 
b/collector/system/src/main/cfg/org.apache.karaf.decanter.collector.system.cfg
index 325acca..7ba77f6 100644
--- 
a/collector/system/src/main/cfg/org.apache.karaf.decanter.collector.system.cfg
+++ 
b/collector/system/src/main/cfg/org.apache.karaf.decanter.collector.system.cfg
@@ -44,3 +44,5 @@
 #
 #   sensors|grep temp1|awk '{print $2}'|cut -b2,3,4,5
 #
+# The system collector tries to detect the output type of your command, trying 
to convert to integer or double and fall
+# back to String
diff --git 
a/collector/system/src/main/java/org/apache/karaf/decanter/collector/system/SystemCollector.java
 
b/collector/system/src/main/java/org/apache/karaf/decanter/collector/system/SystemCollector.java
index 5790ef9..accd986 100644
--- 
a/collector/system/src/main/java/org/apache/karaf/decanter/collector/system/SystemCollector.java
+++ 
b/collector/system/src/main/java/org/apache/karaf/decanter/collector/system/SystemCollector.java
@@ -93,6 +93,7 @@ public void run() {
                         if (output.endsWith("\n")) {
                             output = output.substring(0, output.length() - 1);
                         }
+                        output = output.trim();
                         // try to convert to number
                         try {
                             if (output.contains(".")) {
@@ -103,7 +104,7 @@ public void run() {
                                 data.put(key, value);
                             }
                         } catch (NumberFormatException e) {
-                            data.put(key, outputStream.toString());
+                            data.put(key, output);
                         }
                         streamHandler.stop();
                         Event event = new Event("decanter/collect/system/" + 
key.replace(".", "_"), data);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Add triming in system command output in the system collector to allow clean 
> type conversion
> -------------------------------------------------------------------------------------------
>
>                 Key: KARAF-5864
>                 URL: https://issues.apache.org/jira/browse/KARAF-5864
>             Project: Karaf
>          Issue Type: Improvement
>          Components: decanter
>            Reporter: Jean-Baptiste Onofré
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: decanter-2.1.0
>
>
> The system collector tries to convert the execution output of a the system 
> command to {{double}} or {{integer}} and fallback to {{string}} if the 
> conversion fails.
> However, the system command output can contains leading or trailing space.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to