Module: nagvis Branch: master Commit: f35cd419fc3bb421709c9bbd6332c43f65316bdf URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=f35cd419fc3bb421709c9bbd6332c43f65316bdf
Author: LaMi <[email protected]> Date: Sat Feb 13 19:30:38 2010 +0100 #188 The default background color is now transparent; Automaps can handle the background_color attribute now --- share/server/core/classes/CoreModAutoMap.php | 3 +- share/server/core/classes/NagVisAutoMap.php | 54 ++++++++++++++++++++ share/server/core/classes/objects/NagVisMapObj.php | 2 +- share/server/core/classes/objects/NagiosHost.php | 6 +- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/share/server/core/classes/CoreModAutoMap.php b/share/server/core/classes/CoreModAutoMap.php index 7154abd..a7478cc 100644 --- a/share/server/core/classes/CoreModAutoMap.php +++ b/share/server/core/classes/CoreModAutoMap.php @@ -42,7 +42,8 @@ class CoreModAutoMap extends CoreModule { 'width' => MATCH_INTEGER_EMPTY, 'height' => MATCH_INTEGER_EMPTY, 'ignoreHosts' => MATCH_STRING_NO_SPACE_EMPTY, - 'filterGroup' => MATCH_STRING_NO_SPACE_EMPTY); + 'filterGroup' => MATCH_STRING_NO_SPACE_EMPTY, + 'filterByState' => MATCH_STRING_NO_SPACE_EMPTY); $aVals = $this->getCustomOptions($aOpts); $this->name = $aVals['show']; diff --git a/share/server/core/classes/NagVisAutoMap.php b/share/server/core/classes/NagVisAutoMap.php index 8c44cac..8bf6ea6 100644 --- a/share/server/core/classes/NagVisAutoMap.php +++ b/share/server/core/classes/NagVisAutoMap.php @@ -41,6 +41,7 @@ class NagVisAutoMap extends GlobalMap { private $renderMode; private $ignoreHosts; private $filterGroup; + private $filterByState; private $rootObject; private $arrMapObjects; @@ -164,6 +165,12 @@ class NagVisAutoMap extends GlobalMap { $this->filterGroup = ''; } + if(isset($prop['filterByState']) && $prop['filterByState'] != '') { + $this->filterByState = $prop['filterByState']; + } else { + $this->filterByState = ''; + } + // Get "root" host object $this->fetchHostObjectByName($this->root); @@ -198,6 +205,15 @@ class NagVisAutoMap extends GlobalMap { $this->MAPOBJ = new NagVisMapObj($this->CORE, $this->BACKEND, $this->MAPCFG, $bIsView); $this->MAPOBJ->objectTreeToMapObjects($this->rootObject); $this->MAPOBJ->fetchState(); + + if($this->filterByState != '') { + $this->filterChildObjectTreeByState(); + + // Filter the parent object tree too when enabled + if(isset($this->parentLayers) && $this->parentLayers != 0) { + $this->filterParentObjectTreeByState(); + } + } } /** @@ -565,6 +581,44 @@ class NagVisAutoMap extends GlobalMap { } /** + * PRIVATE filterParentObjectTreeByState() + * + * Filter the parent object tree by state. Only showing objects which + * have some problem. + * + * @author Lars Michelsen <[email protected]> + */ + private function filterParentObjectTreeByState() { + $nonProblemHosts = Array(); + + + $this->rootObject->filterParents($nonProblemHosts); + } + + /** + * PRIVATE filterChildObjectTreeByState() + * + * Filter the child object tree by state. Only showing objects which + * have some problem. + * + * @author Lars Michelsen <[email protected]> + */ + private function filterChildObjectTreeByState() { + $nonProblemHosts = Array(); + + $stateWeight = $this->CORE->getMainCfg()->getStateWeight(); + + foreach($this->arrMapObjects AS $OBJ) { + if($OBJ->getSummaryState() > $stateWeight['OK']) { + $nonProblemHosts[] = $OBJ->getName(); + } + } + print_r($nonProblemHosts); + + $this->rootObject->filterChilds($nonProblemHosts); + } + + /** * PRIVATE filterParentObjectTreeByGroup() * * Filter the parent object tree using the given filter group diff --git a/share/server/core/classes/objects/NagVisMapObj.php b/share/server/core/classes/objects/NagVisMapObj.php index 10ddfe2..c3f9b55 100644 --- a/share/server/core/classes/objects/NagVisMapObj.php +++ b/share/server/core/classes/objects/NagVisMapObj.php @@ -282,7 +282,7 @@ class NagVisMapObj extends NagVisStatefulObject { * @author Lars Michelsen <[email protected]> */ public function objectTreeToMapObjects(&$OBJ, &$arrHostnames=Array()) { - $this->members[] = $OBJ; + $this->members[] = &$OBJ; foreach($OBJ->getChildsAndParents() AS $OBJ1) { /* diff --git a/share/server/core/classes/objects/NagiosHost.php b/share/server/core/classes/objects/NagiosHost.php index 3d93caf..f56c9c3 100644 --- a/share/server/core/classes/objects/NagiosHost.php +++ b/share/server/core/classes/objects/NagiosHost.php @@ -228,10 +228,10 @@ class NagiosHost extends NagVisStatefulObject { } } /** - * PUBLIC filterChilds() + * PUBLIC filterParents() * - * Filters the children depending on the allowed hosts list. All objects which - * are not in the list and are no parent of a host in this list will be + * Filters the parents depending on the allowed hosts list. All objects which + * are not in the list and are no child of a host in this list will be * removed from the map. * * @param Array List of allowed hosts ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
