Module: nagvis
Branch: master
Commit: 381b601e3885f04f33483349e138e49d957958be
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=381b601e3885f04f33483349e138e49d957958be

Author: LaMi <[email protected]>
Date:   Tue Nov 17 11:25:20 2009 +0100

Fixed problem with host state detection and weight in combination with new 
mklivestatus backend

---

 share/frontend/wui/form_handler.php                |   19 ++++---
 .../core/classes/GlobalBackendmklivestatus.php     |    4 +-
 share/server/core/classes/objects/NagiosHost.php   |   54 ++++++++++++++++----
 3 files changed, 57 insertions(+), 20 deletions(-)

diff --git a/share/frontend/wui/form_handler.php 
b/share/frontend/wui/form_handler.php
index 5ca3eef..5abb83f 100644
--- a/share/frontend/wui/form_handler.php
+++ b/share/frontend/wui/form_handler.php
@@ -26,16 +26,21 @@
  * @author     Lars Michelsen <[email protected]>
  */
 
-// Include defines
-require('../nagvis/includes/defines/global.php');
-require('../nagvis/includes/defines/matches.php');
+// Include global defines
+require('../../server/core/defines/global.php');
+require('../../server/core/defines/matches.php');
 
-// Include global functions
-require("../nagvis/includes/functions/autoload.php");
-require('../nagvis/includes/functions/debug.php');
-require("../nagvis/includes/functions/getuser.php");
+// Include wui related defines
+require('defines/wui.php');
+
+// Include functions
+require("../../server/core/functions/autoload.php");
+require("../../server/core/functions/debug.php");
+require("../../server/core/functions/getuser.php");
+require("../../server/core/functions/oldPhpVersionFixes.php");
 
 // Include needed WUI specific functions
+//FIXME: Remove this ...
 require('./functions/form_handler.php');
 
 // This defines wether the GlobalMessage prints HTML or ajax error messages
diff --git a/share/server/core/classes/GlobalBackendmklivestatus.php 
b/share/server/core/classes/GlobalBackendmklivestatus.php
index fda6b0d..7ed523a 100644
--- a/share/server/core/classes/GlobalBackendmklivestatus.php
+++ b/share/server/core/classes/GlobalBackendmklivestatus.php
@@ -688,9 +688,9 @@ class GlobalBackendmklivestatus implements 
GlobalBackendInterface {
                 */
                // $e[15]: acknowledged
                if($state != 'OK' && $e[15] == 1) {
-                       $arrTmpReturn['problem_has_been_acknowledged'] = 1;
+                       $arrReturn['problem_has_been_acknowledged'] = 1;
                } else {
-                       $arrTmpReturn['problem_has_been_acknowledged'] = 0;
+                       $arrReturn['problem_has_been_acknowledged'] = 0;
                }
                
                // If there is a downtime for this object, save the data
diff --git a/share/server/core/classes/objects/NagiosHost.php 
b/share/server/core/classes/objects/NagiosHost.php
index 4a27457..46610f4 100644
--- a/share/server/core/classes/objects/NagiosHost.php
+++ b/share/server/core/classes/objects/NagiosHost.php
@@ -157,6 +157,9 @@ class NagiosHost extends NagVisStatefulObject {
                                // Get state counts
                                $this->aStateCounts = 
$this->BACKEND->BACKENDS[$this->backend_id]->getHostStateCounts($this->host_name,
 $this->only_hard_states);
                                
+                               // Add host state to counts
+                               $this->addHostStateToStateCounts();
+                               
                                // Calculate summary state and output
                                $this->fetchSummariesFromCounts();
                                
@@ -630,7 +633,33 @@ class NagiosHost extends NagVisStatefulObject {
                        }
                }
        }
-       
+               
+       /**
+        * PUBLIC addHostStateToStateCounts()
+        *
+        * Adds the current host state to the member state counts
+        *
+        * @author      Lars Michelsen <[email protected]>
+        */
+       private function addHostStateToStateCounts() {
+               $sState = $this->getState();
+
+               $stateWeight = $this->CORE->getMainCfg()->getStateWeight();
+               
+               $sType = 'normal';
+               if($this->getAcknowledgement() == 1 && 
isset($stateWeight[$sState]['ack'])) {
+                       $sType = 'ack';
+               } elseif($this->getInDowntime() == 1 && 
isset($stateWeight[$sState]['downtime'])) {
+                       $sType = 'downtime';
+               }
+               
+               if(!isset($this->aStateCounts[$sState])) {
+                       $this->aStateCounts[$sState] = Array($sType => 1);
+               } else {
+                       $this->aStateCounts[$sState][$sType] += 1;
+               }
+       }
+
        /**
         * PRIVATE fetchSummaryOutputFromCounts()
         *
@@ -650,16 +679,19 @@ class NagiosHost extends NagVisStatefulObject {
                        
                        // Loop all major states
                        foreach($this->aStateCounts AS $sState => $aSubstates) {
-                               // Loop all substates (normal,ack,downtime,...)
-                               foreach($aSubstates AS $sSubState => $iCount) {
-                                       // Found some objects with this 
state+substate
-                                       if($iCount > 0) {
-                                               
if(!isset($arrServiceStates[$sState])) {
-                                                       
$arrServiceStates[$sState] = $iCount;
-                                                       $iNumServices += 
$iCount;
-                                               } else {
-                                                       
$arrServiceStates[$sState] += $iCount;
-                                                       $iNumServices += 
$iCount;
+                               // Ignore host state here
+                               if($sState != 'UP' && $sState != 'DOWN' && 
$sState != 'UNREACHABLE') {
+                                       // Loop all substates 
(normal,ack,downtime,...)
+                                       foreach($aSubstates AS $sSubState => 
$iCount) {
+                                               // Found some objects with this 
state+substate
+                                               if($iCount > 0) {
+                                                       
if(!isset($arrServiceStates[$sState])) {
+                                                               
$arrServiceStates[$sState] = $iCount;
+                                                               $iNumServices 
+= $iCount;
+                                                       } else {
+                                                               
$arrServiceStates[$sState] += $iCount;
+                                                               $iNumServices 
+= $iCount;
+                                                       }
                                                }
                                        }
                                }


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to