[icinga-checkins] icinga.org: icingaweb2/master: Sort the hostgroup- and servicegroupsummary by service severity

git at icinga.org git at icinga.org
Thu Nov 20 10:08:01 CET 2014


Module: icingaweb2
Branch: master
Commit: 2fdc1f4322981fde2e0cc391e2a54d783b491282
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=2fdc1f4322981fde2e0cc391e2a54d783b491282

Author: Johannes Meyer <johannes.meyer at netways.de>
Date:   Thu Nov 20 09:48:47 2014 +0100

Sort the hostgroup- and servicegroupsummary by service severity

---

 .../Backend/Ido/Query/GroupsummaryQuery.php        |    8 ++++---
 .../library/Monitoring/DataView/Groupsummary.php   |   22 +++++++++++++++++++-
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php
index d38c40c..17e1061 100644
--- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php
+++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/GroupsummaryQuery.php
@@ -4,7 +4,6 @@
 
 namespace Icinga\Module\Monitoring\Backend\Ido\Query;
 
-use Icinga\Application\Logger;
 use Zend_Db_Select;
 
 class GroupSummaryQuery extends IdoQuery
@@ -36,6 +35,7 @@ class GroupSummaryQuery extends IdoQuery
             'services_warning_unhandled'    => 'SUM(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)',
             'services_critical_unhandled'   => 'SUM(CASE WHEN object_type = \'service\' AND state = 2 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)',
             'services_unknown_unhandled'    => 'SUM(CASE WHEN object_type = \'service\' AND state = 3 AND acknowledged + in_downtime + host_state = 0 THEN 1 ELSE 0 END)',
+            'services_highest_severity'                     => 'MAX(CASE WHEN object_type = \'service\' THEN severity ELSE 0 END)',
             'services_ok_last_state_change'                 => 'MAX(CASE WHEN object_type = \'service\' AND state = 0 THEN state_change ELSE 0 END)',
             'services_pending_last_state_change'            => 'MAX(CASE WHEN object_type = \'service\' AND state = 99 THEN state_change ELSE 0 END)',
             'services_warning_last_state_change_handled'    => 'MAX(CASE WHEN object_type = \'service\' AND state = 1 AND acknowledged + in_downtime + host_state > 0 THEN state_change ELSE 0 END)',
@@ -67,7 +67,8 @@ class GroupSummaryQuery extends IdoQuery
                 'state'        => 'host_state',
                 'acknowledged' => 'host_acknowledged',
                 'in_downtime'  => 'host_in_downtime',
-                'state_change' => 'host_last_state_change'
+                'state_change' => 'host_last_state_change',
+                'severity'     => 'host_severity'
             )
         );
         if (in_array('servicegroup', $this->desiredColumns)) {
@@ -79,7 +80,8 @@ class GroupSummaryQuery extends IdoQuery
                 'state'        => 'service_state',
                 'acknowledged' => 'service_acknowledged',
                 'in_downtime'  => 'service_in_downtime',
-                'state_change' => 'service_last_state_change'
+                'state_change' => 'service_last_state_change',
+                'severity'     => 'service_severity'
             )
         );
 
diff --git a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php
index 72b021f..40c44ac 100644
--- a/modules/monitoring/library/Monitoring/DataView/Groupsummary.php
+++ b/modules/monitoring/library/Monitoring/DataView/Groupsummary.php
@@ -24,6 +24,7 @@ class Groupsummary extends DataView
             'hosts_down_handled',
             'hosts_down_unhandled',
             'hosts_pending',
+            'services_total',
             'services_ok',
             'services_unknown',
             'services_unknown_handled',
@@ -34,7 +35,26 @@ class Groupsummary extends DataView
             'services_warning',
             'services_warning_handled',
             'services_warning_unhandled',
-            'services_pending'
+            'services_pending',
+            'services_highest_severity',
+            'services_ok_last_state_change',
+            'services_pending_last_state_change',
+            'services_warning_last_state_change_handled',
+            'services_critical_last_state_change_handled',
+            'services_unknown_last_state_change_handled',
+            'services_warning_last_state_change_unhandled',
+            'services_critical_last_state_change_unhandled',
+            'services_unknown_last_state_change_unhandled'
+        );
+    }
+    
+    public function getSortRules()
+    {
+        return array(
+            'services_highest_severity' => array(
+                'columns'   => array('services_highest_severity'),
+                'order'     => self::SORT_DESC
+            )
         );
     }
 }



More information about the icinga-checkins mailing list