Author: Lars Michelsen <[email protected]>
Date: Mon Aug 15 14:34:15 2011 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Mon Aug 15 14:34:15 2011 +0200
Some additional small cleanups
---
share/server/core/classes/NagVisAutoMap.php | 2 +-
share/server/core/classes/objects/NagVisMapObj.php | 10 ++++++--
share/server/core/classes/objects/NagVisObject.php | 4 +-
.../core/classes/objects/NagVisStatefulObject.php | 23 ++++++++++++-------
share/server/core/classes/objects/NagiosHost.php | 21 +++++-------------
.../core/classes/objects/NagiosServicegroup.php | 2 +-
share/server/core/defines/global.php | 1 +
7 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/share/server/core/classes/NagVisAutoMap.php
b/share/server/core/classes/NagVisAutoMap.php
index c9e2eaf..ea5a94a 100644
--- a/share/server/core/classes/NagVisAutoMap.php
+++ b/share/server/core/classes/NagVisAutoMap.php
@@ -770,7 +770,7 @@ class NagVisAutoMap extends GlobalMap {
foreach($this->arrMapObjects AS $OBJ) {
if(isset($stateWeight[$OBJ->getSummaryState()])
- &&
$stateWeight[$OBJ->getSummaryState()][$OBJ->getSummarySubState()] >
$stateWeight['UP']['normal']) {
+ &&
$stateWeight[$OBJ->getSummaryState()][$OBJ->getSubState(SUMMARY_STATE)] >
$stateWeight['UP']['normal']) {
$problemHosts[] = $OBJ->getName();
}
}
diff --git a/share/server/core/classes/objects/NagVisMapObj.php
b/share/server/core/classes/objects/NagVisMapObj.php
index 674a944..a691d77 100644
--- a/share/server/core/classes/objects/NagVisMapObj.php
+++ b/share/server/core/classes/objects/NagVisMapObj.php
@@ -496,7 +496,10 @@ class NagVisMapObj extends NagVisStatefulObject {
*/
private function fetchSummaryOutput() {
if($this->hasObjects() && $this->hasStatefulObjects()) {
- $arrStates = Array('UNREACHABLE' => 0, 'CRITICAL' => 0,'DOWN' =>
0,'WARNING' => 0,'UNKNOWN' => 0,'UP' => 0,'OK' => 0,'ERROR' => 0,'ACK' =>
0,'PENDING' => 0);
+ $arrStates = Array('UNREACHABLE' => 0, 'CRITICAL' => 0, 'DOWN' =>
0,
+ 'WARNING' => 0, 'UNKNOWN' => 0, 'UP' =>
0,
+ 'OK' => 0, 'ERROR' => 0, 'ACK' =>
0,
+ 'PENDING' => 0);
foreach($this->getStateRelevantMembers() AS $OBJ)
if(isset($arrStates[$OBJ->summary_state]))
@@ -518,7 +521,8 @@ class NagVisMapObj extends NagVisStatefulObject {
* @author Lars Michelsen <[email protected]>
*/
private function isPermitted($OBJ) {
- if($this->CORE->getAuthorization() !== null &&
$this->CORE->getAuthorization()->isPermitted('Map', 'view', $OBJ->getName()))
+ if($this->CORE->getAuthorization() !== null
+ && $this->CORE->getAuthorization()->isPermitted('Map', 'view',
$OBJ->getName()))
return true;
else {
$OBJ->summary_state = 'UNKNOWN';
@@ -543,4 +547,4 @@ class NagVisMapObj extends NagVisStatefulObject {
$this->summary_state = 'UNKNOWN';
}
}
-?>
\ No newline at end of file
+?>
diff --git a/share/server/core/classes/objects/NagVisObject.php
b/share/server/core/classes/objects/NagVisObject.php
index 3acb267..caae394 100644
--- a/share/server/core/classes/objects/NagVisObject.php
+++ b/share/server/core/classes/objects/NagVisObject.php
@@ -569,8 +569,8 @@ class NagVisObject {
// Handle normal/ack/downtime states
- $stubState1 = $OBJ1->getSummarySubState();
- $stubState2 = $OBJ2->getSummarySubState();
+ $stubState1 = $OBJ1->getSubState(SUMMARY_STATE);
+ $stubState2 = $OBJ2->getSubState(SUMMARY_STATE);
if(NagVisObject::$stateWeight[$state1][$stubState1] ==
NagVisObject::$stateWeight[$state2][$stubState2]) {
return 0;
diff --git a/share/server/core/classes/objects/NagVisStatefulObject.php
b/share/server/core/classes/objects/NagVisStatefulObject.php
index 577c30c..45721a1 100644
--- a/share/server/core/classes/objects/NagVisStatefulObject.php
+++ b/share/server/core/classes/objects/NagVisStatefulObject.php
@@ -326,13 +326,18 @@ class NagVisStatefulObject extends NagVisObject {
/**
* Returns the current sub-state of the object
*/
- public function getSummarySubState() {
- if($this->summary_problem_has_been_acknowledged == 1)
- return 'ack';
- elseif($this->summary_in_downtime == 1)
- return 'downtime';
+ public function getSubState($summary = false) {
+ if($summary)
+ if($this->summary_problem_has_been_acknowledged == 1)
+ return 'ack';
+ elseif($this->summary_in_downtime == 1)
+ return 'downtime';
else
- return 'normal';
+ if($this->problem_has_been_acknowledged == 1)
+ return 'ack';
+ elseif($this->in_downtime == 1)
+ return 'downtime';
+ return 'normal';
}
/**
@@ -808,10 +813,10 @@ class NagVisStatefulObject extends NagVisObject {
$currWeight = null;
} else {
if(isset(NagVisObject::$stateWeight[$this->summary_state])) {
- $currWeight =
NagVisObject::$stateWeight[$this->summary_state][$this->getSummarySubState()];
+ $currWeight =
NagVisObject::$stateWeight[$this->summary_state][$this->getSubState(SUMMARY_STATE)];
} else {
// Error handling: Invalid state
- new GlobalMessage('ERROR',
GlobalCore::getInstance()->getLang()->getText('Invalid state+substate ([STATE],
[SUBSTATE]) found while loading the current summary state of an object of type
[TYPE].', Array('STATE' => $this->summary_state, 'SUBSTATE' =>
$this->getSummarySubState(), 'TYPE' => $this->getType())));
+ new GlobalMessage('ERROR',
GlobalCore::getInstance()->getLang()->getText('Invalid state+substate ([STATE],
[SUBSTATE]) found while loading the current summary state of an object of type
[TYPE].', Array('STATE' => $this->summary_state, 'SUBSTATE' =>
$this->getSubState(SUMMARY_STATE), 'TYPE' => $this->getType())));
}
}
@@ -907,7 +912,7 @@ class NagVisStatefulObject extends NagVisObject {
// Initialize empty or with current object state
$currentStateWeight = null;
if($this->summary_state != '')
- $currentStateWeight =
NagVisObject::$stateWeight[$this->summary_state][$this->getSummarySubState()];
+ $currentStateWeight =
NagVisObject::$stateWeight[$this->summary_state][$this->getSubState(SUMMARY_STATE)];
// Loop all object to gather the worst state and set it as summary
// state of the current object
diff --git a/share/server/core/classes/objects/NagiosHost.php
b/share/server/core/classes/objects/NagiosHost.php
index 989f07d..cdbbe78 100644
--- a/share/server/core/classes/objects/NagiosHost.php
+++ b/share/server/core/classes/objects/NagiosHost.php
@@ -571,22 +571,13 @@ class NagiosHost extends NagVisStatefulObject {
private function addHostStateToStateCounts() {
$sState = $this->state;
- if(NagVisObject::$stateWeight === null)
- NagVisObject::$stateWeight =
$this->CORE->getMainCfg()->getStateWeight();
-
- $sType = 'normal';
- if($this->problem_has_been_acknowledged == 1 &&
isset(NagVisObject::$stateWeight[$sState]['ack'])) {
- $sType = 'ack';
- } elseif($this->in_downtime == 1 &&
isset(NagVisObject::$stateWeight[$sState]['downtime'])) {
- $sType = 'downtime';
- }
-
+ $sSubState = $this->getSubState();
if(!isset($this->aStateCounts[$sState]))
- $this->aStateCounts[$sState] = Array($sType => 1);
- elseif(!isset($this->aStateCounts[$sState][$sType]))
- $this->aStateCounts[$sState][$sType] = 1;
+ $this->aStateCounts[$sState] = Array($sSubState => 1);
+ elseif(!isset($this->aStateCounts[$sState][$sSubState]))
+ $this->aStateCounts[$sState][$sSubState] = 1;
else
- $this->aStateCounts[$sState][$sType] += 1;
+ $this->aStateCounts[$sState][$sSubState] += 1;
}
/**
@@ -660,7 +651,7 @@ class NagiosHost extends NagVisStatefulObject {
if($this->hasMembers()) {
$arrStates = Array('CRITICAL' => 0, 'DOWN' => 0, 'WARNING'
=> 0,
'UNKNOWN' => 0, 'UP' => 0, 'OK'
=> 0,
- 'ERROR' => 0,
'PENDING' => 0, 'UNCHECKED' => 0);
+ 'ERROR' => 0, 'PENDING' => 0,
'UNCHECKED' => 0);
foreach($this->members AS &$SERVICE) {
$arrStates[$SERVICE->getSummaryState()]++;
diff --git a/share/server/core/classes/objects/NagiosServicegroup.php
b/share/server/core/classes/objects/NagiosServicegroup.php
index 4e27e1c..f54a270 100644
--- a/share/server/core/classes/objects/NagiosServicegroup.php
+++ b/share/server/core/classes/objects/NagiosServicegroup.php
@@ -228,4 +228,4 @@ class NagiosServicegroup extends NagVisStatefulObject {
}
}
}
-?>
\ No newline at end of file
+?>
diff --git a/share/server/core/defines/global.php
b/share/server/core/defines/global.php
index e17e5ba..2c608c1 100644
--- a/share/server/core/defines/global.php
+++ b/share/server/core/defines/global.php
@@ -108,6 +108,7 @@ define('IS_VIEW', true);
define('ONLY_GLOBAL', true);
define('GET_CHILDS', true);
define('SET_KEYS', true);
+define('SUMMARY_STATE', true);
// Maximum length for usernames/passwords
define('AUTH_MAX_PASSWORD_LENGTH', 30);
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
user administration capabilities and model configuration. Take
the hassle out of deploying and managing Subversion and the
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins