[icinga-checkins] icinga.org: icinga-web/master: * Fixed performance calculations not being calculated like in the cgis ( fixes #2446(

git at icinga.org git at icinga.org
Wed Apr 25 11:46:15 CEST 2012


Module: icinga-web
Branch: master
Commit: 6e12f7c2d4f9c1bb0e4ed77aa968846bbff56a9a
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=6e12f7c2d4f9c1bb0e4ed77aa968846bbff56a9a

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Wed Apr 25 11:38:49 2012 +0200

* Fixed performance calculations not being calculated like in the cgis (fixes #2446(

---

 .../Cronks/lib/js/Cronks/MonitorPerformance.js     |   13 ++++++-----
 .../Provider/SystemPerformanceModel.class.php      |   22 +++++++++++++------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/app/modules/Cronks/lib/js/Cronks/MonitorPerformance.js b/app/modules/Cronks/lib/js/Cronks/MonitorPerformance.js
index 6b948cb..ac2f9d9 100644
--- a/app/modules/Cronks/lib/js/Cronks/MonitorPerformance.js
+++ b/app/modules/Cronks/lib/js/Cronks/MonitorPerformance.js
@@ -62,15 +62,16 @@ Ext.ns('Icinga.Cronks.System.MonitorPerformance');
 
                 '<div class="clearfix icinga-monitor-performance-container">',
                     '<div title="' + _('Host execution time (min/avg/max)') + '" class="key icinga-icon-execution-time"></div>',
-                    '<div class="value">{host_execution_time_min} / {host_execution_time_avg} / {host_execution_time_max}</div>',
+                    '<div class="value">{host_execution_time_min} / {host_execution_time_max} / {host_execution_time_avg}</div>',
                 '</div>',
 
                 '<div class="clearfix icinga-monitor-performance-container">',
                     '<div title="' + _('Host latency (min/avg/max)') + '" class="key icinga-icon-latency"></div>',
                     '<div class="value">{host_latency_min} / ',
+                    '{host_latency_max} / ',
                     '<tpl if="host_latency_avg > '+this.hostThreshold+'"><span style="color:red" ext:qtip="Threshold reached"> {host_latency_avg} </span></tpl>',
                     '<tpl if="host_latency_avg <= '+this.hostThreshold+'">{host_latency_avg} </tpl>',
-                    ' / {host_latency_max}</div>',
+                    '</div>',
                 '</div>',
 
             '</div>',
@@ -84,15 +85,15 @@ Ext.ns('Icinga.Cronks.System.MonitorPerformance');
 
                 '<div class="clearfix icinga-monitor-performance-container">',
                     '<div title="' + _('Service execution (min/avg/max)') + '" class="key icinga-icon-execution-time"></div>',
-                    '<div class="value">{service_execution_time_min} / {service_execution_time_avg} / {service_execution_time_max}</div>',
+                    '<div class="value">{service_execution_time_min} / {service_execution_time_max} / {service_execution_time_avg}</div>',
                 '</div>',
 
                 '<div class="clearfix icinga-monitor-performance-container">',
                     '<div title="' + _('Service latency (min/avg/max)') + '" class="key icinga-icon-latency"></div>',
-                    '<div class="value">{service_latency_min} / ',
+                    '<div class="value">{service_latency_min} / {service_latency_max} /',
                     '<tpl if="service_latency_avg > '+this.serviceThreshold+'"><span style="color:red" ext:qtip="Threshold reached"> {service_latency_avg} </span></tpl>',
                     '<tpl if="service_latency_avg <= '+this.serviceThreshold+'">{service_latency_avg} </tpl>',
-                    ' / {service_latency_avg}</div>',
+                    '</div>',
                 '</div>',
 
             '</div>',
@@ -149,4 +150,4 @@ Ext.ns('Icinga.Cronks.System.MonitorPerformance');
 		}
 		
 	});
-})();
\ No newline at end of file
+})();
diff --git a/app/modules/Cronks/models/Provider/SystemPerformanceModel.class.php b/app/modules/Cronks/models/Provider/SystemPerformanceModel.class.php
index 6790f75..a93dfd9 100644
--- a/app/modules/Cronks/models/Provider/SystemPerformanceModel.class.php
+++ b/app/modules/Cronks/models/Provider/SystemPerformanceModel.class.php
@@ -62,27 +62,35 @@ class Cronks_Provider_SystemPerformanceModel extends CronksBaseModel {
         $this->checkObjectType($type);
         
         $table = null;
+        $joinTable = null;
         $prefix = null;
         
         if ($type===IcingaConstants::TYPE_HOST) {
             $table = 'IcingaHoststatus';
+            $joinTable = 'host';
             $prefix = 'host';
         } else {
             $table = 'IcingaServicestatus';
+            $joinTable = 'service'; 
             $prefix = 'service';
         }
         
         $data = IcingaDoctrine_Query::create()
         ->from($table. ' '. $prefix)
-        ->select(sprintf('MIN(%1$s) as %1$s_min, MAX(%1$s) as %1$s_max, AVG(%1$s) as %1$s_avg', $field))
+        ->select(sprintf($prefix.'.active_checks_enabled, COUNT(%1$s) as count, SUM(%1$s) as sum,MAX(%1$s) as max,MIN(%1$s) as min',$field))
+        ->having($prefix.'.active_checks_enabled = ?','1')
+        ->innerJoin($prefix.".".$joinTable)
         ->disableAutoIdentifierFields(true)
         ->execute(array(), Doctrine::HYDRATE_SCALAR);
-        
+   
+        $result = array();
         if (is_array($data) && count($data) === 1) {
-            foreach ($data[0] as $k=>&$v) {
-                $v = sprintf('%.3f', $v);
-            }
-            return $data[0];
+            $data = $data[0];
+
+            $result[$prefix."_".$field."_min"] = sprintf('%.3f',$data[$prefix."_min"]);
+            $result[$prefix."_".$field."_avg"] = sprintf('%.3f',$data[$prefix."_sum"]/$data[$prefix."_count"]);
+            $result[$prefix."_".$field."_max"] = sprintf('%.3f',$data[$prefix."_max"]);
+            return $result;
         }
     }
     
@@ -107,4 +115,4 @@ class Cronks_Provider_SystemPerformanceModel extends CronksBaseModel {
         $json->setSuccess(true);
         return $json;
     }
-}
\ No newline at end of file
+}





More information about the icinga-checkins mailing list