Repository: karaf-decanter Updated Branches: refs/heads/master 86df6397f -> 4af1f294d
[KARAF-4532] Prefix keys with command prefix in the system collector Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/4af1f294 Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/4af1f294 Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/4af1f294 Branch: refs/heads/master Commit: 4af1f294dd838317ebb512e126a5ee7ab748ab8a Parents: 86df639 Author: Jean-Baptiste Onofré <[email protected]> Authored: Sun Jul 31 10:57:06 2016 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Sun Jul 31 10:57:06 2016 +0200 ---------------------------------------------------------------------- .../org.apache.karaf.decanter.collector.system.cfg | 12 ++++++++---- .../decanter/collector/system/SystemCollector.java | 4 ++-- manual/src/main/asciidoc/user-guide/collectors.adoc | 16 ++++++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/4af1f294/collector/system/src/main/cfg/org.apache.karaf.decanter.collector.system.cfg ---------------------------------------------------------------------- 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 b6e109a..38c80af 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 @@ -5,17 +5,21 @@ # This collector executes system commands, retrieve the exec output/err # sent to the appenders # -# The format is key=command +# The format is command.key=command_to_execute +# where command is a reserved keyword used to identify a command property # for instance: -# df=df -h -# free=free +# +# command.df=df -h +# command.free=free +# # You can also create a script containing command like: # # df -k / | awk -F " |%" '/dev/{print $8}' # # This script will get the available space on the / filesystem for instance. # and call the script: -# df=/bin/script +# +# command.df=/bin/script # # Another example of script to get the temperature: # http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/4af1f294/collector/system/src/main/java/org/apache/karaf/decanter/collector/system/SystemCollector.java ---------------------------------------------------------------------- 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 105d38d..387eb78 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 @@ -67,7 +67,7 @@ public class SystemCollector implements Runnable { while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); try { - if (!key.equals("felix.fileinstall.filename") && !key.equals("service.pid")) { + if (key.startsWith("command.")) { HashMap<String, Object> data = new HashMap<>(); String command = (String) properties.get(key); LOGGER.debug("Executing {} ({})", command, key); @@ -100,7 +100,7 @@ public class SystemCollector implements Runnable { data.put(key, outputStream.toString()); } streamHandler.stop(); - Event event = new Event("decanter/collect/system/" + key, data); + Event event = new Event("decanter/collect/system/" + key.replace(".", "_"), data); eventAdmin.postEvent(event); try { outputStream.close(); http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/4af1f294/manual/src/main/asciidoc/user-guide/collectors.adoc ---------------------------------------------------------------------- diff --git a/manual/src/main/asciidoc/user-guide/collectors.adoc b/manual/src/main/asciidoc/user-guide/collectors.adoc index c110750..6ed909b 100644 --- a/manual/src/main/asciidoc/user-guide/collectors.adoc +++ b/manual/src/main/asciidoc/user-guide/collectors.adoc @@ -378,17 +378,21 @@ This feature installs a default `etc/org.apache.karaf.decanter.collector.system. # This collector executes system commands, retrieve the exec output/err # sent to the appenders # -# The format is key=command +# The format is command.key=command_to_execute +# where command is a reserved keyword used to identify a command property # for instance: -# df=df -h -# free=free +# +# command.df=df -h +# command.free=free +# # You can also create a script containing command like: # # df -k / | awk -F " |%" '/dev/{print $8}' # # This script will get the available space on the / filesystem for instance. # and call the script: -# df=/bin/script +# +# command.df=/bin/script # # Another example of script to get the temperature: # @@ -399,7 +403,7 @@ This feature installs a default `etc/org.apache.karaf.decanter.collector.system. You can add the commands that you want to execute using the format: ---- -name=command +command.name=system_command ---- The collector will execute each command described in this file, and send the execution output to the appenders. @@ -407,5 +411,5 @@ The collector will execute each command described in this file, and send the exe For instance, if you want to periodically send the free space available on the / filesystem, you can add: ---- -df=df -k / | awk -F " |%" '/dev/{print $8}' +command.df=df -k / | awk -F " |%" '/dev/{print $8}' ----
