[icinga-checkins] icinga.org: icingaweb2-module-logstash/master: Add choice for listing found events in check

git at icinga.org git at icinga.org
Fri Feb 5 14:05:50 CET 2016


Module: icingaweb2-module-logstash
Branch: master
Commit: 5ac545c37661a611eecefed65b469d268adc6b7e
URL:    https://git.icinga.org/?p=icingaweb2-module-logstash.git;a=commit;h=5ac545c37661a611eecefed65b469d268adc6b7e

Author: Markus Frosch <markus at lazyfrosch.de>
Date:   Wed Jun 24 09:21:45 2015 +0200

Add choice for listing found events in check

---

 application/clicommands/CheckCommand.php |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/application/clicommands/CheckCommand.php b/application/clicommands/CheckCommand.php
index 07719f5..4274540 100644
--- a/application/clicommands/CheckCommand.php
+++ b/application/clicommands/CheckCommand.php
@@ -49,11 +49,12 @@ class CheckCommand extends Command {
      * Usage: icingacli logstash check <options>
      *
      * Options:
-     *   -Q --query    Elasticsearch query string for events
-     *   -F --filter   Elasticsearch filter string for the queried events
-     *   -f --fields   A comma separated list of fields to show in the output (optional)
-     *   -W --warning  Filter string to match warning events (similar to Elasticsearch)
-     *   -C --critical Filter string to match critical events (similar to Elasticsearch)
+     *   --query    Elasticsearch query string for events
+     *   --filter   Elasticsearch filter string for the queried events
+     *   --fields   A comma separated list of fields to show in the output (optional)
+     *   --warning  Filter string to match warning events (similar to Elasticsearch)
+     *   --critical Filter string to match critical events (similar to Elasticsearch)
+     *   --list     List found events in command output
      *
      * Note: these options are the same as in the web frontend!
      */
@@ -64,6 +65,7 @@ class CheckCommand extends Command {
         $fields = $this->params->get('fields');
         $warning = $this->params->get('warning');
         $critical = $this->params->get('critical');
+        $list = $this->params->get('list');
 
         // internal limit - try not to temper with it
         $limit = 1000;
@@ -107,17 +109,18 @@ class CheckCommand extends Command {
                 $status = 1;
             elseif ($critical > 0)
                 $status = 2;
-            elseif ($count > $limit) {
+            else
+                $status = 0;
+
+            if ($count > $limit) {
                 $message .= sprintf(", we found more than %d events, Icinga State calculation is incorrect!",
                     $limit
                 );
                 $status = 3;
             }
-            else
-                $status = 0;
 
             $long = array();
-            if ($fields) {
+            if ($list and $fields) {
                 $fieldlist = preg_split('/\s*,\s*/', trim($fields));
                 foreach($events as $event) {
                     $line = array();



More information about the icinga-checkins mailing list