Module: nagvis Branch: master Commit: 1e3fb42ef938bb3ebe48df82d7a2a9e792622de9 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=1e3fb42ef938bb3ebe48df82d7a2a9e792622de9
Author: LaMi <[email protected]> Date: Sat Feb 13 19:48:15 2010 +0100 #25 Added parameter filterByState to add a problem automap which filters out all OK/UP branches --- docs/en_US/automap.html | 3 +++ .../nagvis-js/classes/FrontendModAutoMap.php | 1 + share/server/core/classes/NagVisAutoMap.php | 13 +++++++++++-- share/server/core/classes/objects/NagVisMapObj.php | 18 ++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/en_US/automap.html b/docs/en_US/automap.html index 432b139..d38f605 100644 --- a/docs/en_US/automap.html +++ b/docs/en_US/automap.html @@ -69,6 +69,9 @@ <td>ignoreHosts</td><td> none </td><td> comma separated list of hosts (including children) not to display </td> </tr> <tr> + <td>filterByState</td><td>none</td><td>Set to 1 to enable the "problem automap" mode. When it is set to 1 it will filter all branches out which have only OK/UP hosts. This will result in a "problem automap" which only shows up a tree where each branch has at least one problem. (<font color="#ff0000">New in 1.5</font>)</td> + </tr> + <tr> <td>filterGroup</td><td>none</td><td>Provide a hostgroup name. Only hosts in this hostgroup will be shown on the map.</td> </tr> <tr> diff --git a/share/frontend/nagvis-js/classes/FrontendModAutoMap.php b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php index 8a5f7f6..5d57c88 100644 --- a/share/frontend/nagvis-js/classes/FrontendModAutoMap.php +++ b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php @@ -48,6 +48,7 @@ class FrontendModAutoMap extends FrontendModule { 'height' => MATCH_INTEGER_EMPTY, 'ignoreHosts' => MATCH_STRING_NO_SPACE_EMPTY, 'filterGroup' => MATCH_STRING_NO_SPACE_EMPTY, + 'filterByState' => MATCH_STRING_NO_SPACE_EMPTY, 'rotation' => MATCH_ROTATION_NAME_EMPTY, 'enableHeader' => MATCH_BOOLEAN_EMPTY, 'enableContext' => MATCH_BOOLEAN_EMPTY, diff --git a/share/server/core/classes/NagVisAutoMap.php b/share/server/core/classes/NagVisAutoMap.php index 8bf6ea6..9b0a996 100644 --- a/share/server/core/classes/NagVisAutoMap.php +++ b/share/server/core/classes/NagVisAutoMap.php @@ -213,6 +213,9 @@ class NagVisAutoMap extends GlobalMap { if(isset($this->parentLayers) && $this->parentLayers != 0) { $this->filterParentObjectTreeByState(); } + + $this->MAPOBJ->clearMembers(); + $this->MAPOBJ->objectTreeToMapObjects($this->rootObject); } } @@ -591,6 +594,13 @@ class NagVisAutoMap extends GlobalMap { private function filterParentObjectTreeByState() { $nonProblemHosts = Array(); + $stateWeight = $this->CORE->getMainCfg()->getStateWeight(); + + foreach($this->arrMapObjects AS $OBJ) { + if($stateWeight[$OBJ->getSummaryState()] > $stateWeight['OK']) { + $nonProblemHosts[] = $OBJ->getName(); + } + } $this->rootObject->filterParents($nonProblemHosts); } @@ -609,11 +619,10 @@ class NagVisAutoMap extends GlobalMap { $stateWeight = $this->CORE->getMainCfg()->getStateWeight(); foreach($this->arrMapObjects AS $OBJ) { - if($OBJ->getSummaryState() > $stateWeight['OK']) { + if($stateWeight[$OBJ->getSummaryState()] > $stateWeight['OK']) { $nonProblemHosts[] = $OBJ->getName(); } } - print_r($nonProblemHosts); $this->rootObject->filterChilds($nonProblemHosts); } diff --git a/share/server/core/classes/objects/NagVisMapObj.php b/share/server/core/classes/objects/NagVisMapObj.php index c3f9b55..282051d 100644 --- a/share/server/core/classes/objects/NagVisMapObj.php +++ b/share/server/core/classes/objects/NagVisMapObj.php @@ -62,17 +62,31 @@ class NagVisMapObj extends NagVisStatefulObject { $this->alias = $this->MAPCFG->getAlias(); $this->type = 'map'; $this->iconset = 'std_medium'; - $this->members = Array(); + $this->linkedMaps = Array(); $this->isSummaryObject = false; $this->isView = $bIsView; + $this->clearMembers(); + $this->backend_id = $this->MAPCFG->getValue('global', 0, 'backend_id'); parent::__construct($CORE, $BACKEND); } /** + * PUBLIC clearMembers() + * + * Clears the map + * + * @return Array Array with map objects + * @author Lars Michelsen <[email protected]> + */ + public function clearMembers() { + $this->members = Array(); + } + + /** * PUBLIC getMembers() * * Returns the array of objects on the map @@ -282,7 +296,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) { /* ------------------------------------------------------------------------------ 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
