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

Author: Lars Michelsen <[email protected]>
Date:   Tue Jan 18 18:48:00 2011 +0100

Some preps for minor automap improvements

---

 share/server/core/classes/NagVisAutoMap.php      |   35 ++++++++++++++++++++--
 share/server/core/classes/objects/NagVisHost.php |    4 ++
 share/server/core/classes/objects/NagiosHost.php |   13 ++++----
 3 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/share/server/core/classes/NagVisAutoMap.php 
b/share/server/core/classes/NagVisAutoMap.php
index 67f4b9d..4257066 100644
--- a/share/server/core/classes/NagVisAutoMap.php
+++ b/share/server/core/classes/NagVisAutoMap.php
@@ -192,11 +192,21 @@ class NagVisAutoMap extends GlobalMap {
                        if(isset($this->parentLayers) && $this->parentLayers != 
0)
                                $this->rootObject->filterParents($names);
                }
+
+               /**
+                * Here we have all objects within the given layers in the tree 
- completely unfiltered!
+                * Optionally: Apply the filters below
+                */
                
                /**
                 * It is possible to filter the object tree by a hostgroup.
                 * In this mode a list of hostnames in this group is fetched 
and the
                 * parent/child trees are filtered using this list.
+                *
+                * Added later: It is possible that a host of the given group 
is behind a
+                * host which is not in the group. These 'connector' hosts need 
to be added
+                * too. Those hosts will be added by default but this can be 
disabled by
+                * config option. This sort of hosts should be visualized in 
another way.
                 */
                if($this->filterGroup != '') {
                        $this->filterGroupObject = new 
NagVisHostgroup($this->CORE, $this->BACKEND, $this->backend_id, 
$this->filterGroup);
@@ -438,12 +448,31 @@ class NagVisAutoMap extends GlobalMap {
                                                        
                                                        // FIXME: z-index 
configurable?
                                                        // Header menu has 
z-index 100, this object's label the below+1
-                                                       $aObjCoords[$name1] = 
Array('x' => $aCoords[0], 'y' => $aCoords[1], 'z' => 98);
+                                                       $aObjCoords[$name1] = 
Array('x' => $aCoords[0],
+                                                                               
    'y' => $aCoords[1],
+                                                                               
    'z' => 98);
                                                break;
                                                case 'poly':
-                                                       //$aCoords = 
explode(',', $coords);
+                                                       // Get the middle of 
the polygon and substract the object size
+                                                       $x = null;
+                                                       $y = null;
+                                                       $aCoords = explode(' ', 
$coords);
+                                                       foreach($aCoords AS 
$coord) {
+                                                               list($newX, 
$newY) = explode(',', $coord);
+                                                               if($x === null) 
{
+                                                                       $x = 
$newX;
+                                                                       $y = 
$newY;
+                                                               } else {
+                                                                       $x = 
($x + $newX) / 2;
+                                                                       $y = 
($y + $newY) / 2;
+                                                               }
+                                                       }
+                                                       $x -= 16;
+                                                       $y -= 16;
                                                
-                                                       //$aObjCoords[$name1] = 
Array('x' => $aCoords[0], 'y' => $aCoords[1], 'z' => 101);
+                                                       $aObjCoords[$name1] = 
Array('x' => $x,
+                                                                               
    'y' => $y,
+                                                                               
    'z' => 98);
                                                break;
                                        }
                                }
diff --git a/share/server/core/classes/objects/NagVisHost.php 
b/share/server/core/classes/objects/NagVisHost.php
index 9a4e445..5eb2bde 100644
--- a/share/server/core/classes/objects/NagVisHost.php
+++ b/share/server/core/classes/objects/NagVisHost.php
@@ -99,6 +99,10 @@ class NagVisHost extends NagiosHost {
                        if($height != 16) {
                                $strReturn .= 
'height="'.$this->pxToInch($height).'", ';
                        }
+
+                       // The automap connector hosts could be smaller
+                       //if($this->automapConnector)
+                       //      $strReturn .= 
'height="'.$this->pxToInch($width/2).'", width="'.$this->pxToInch($width/2).'", 
';
                        
                        $strReturn .= 'layer="'.$layer.'"';
                        $strReturn .= ' ];'."\n ";
diff --git a/share/server/core/classes/objects/NagiosHost.php 
b/share/server/core/classes/objects/NagiosHost.php
index ca087a9..7c0008d 100644
--- a/share/server/core/classes/objects/NagiosHost.php
+++ b/share/server/core/classes/objects/NagiosHost.php
@@ -54,6 +54,9 @@ class NagiosHost extends NagVisStatefulObject {
        protected $childObjects;
        protected $parentObjects;
        protected $members;
+       // An automap connector is a host which is not part of the automap 
selection
+       // but needed as 'bridge' between two hosts which are part of the 
automap
+       protected $automapConnector = false;
 
        protected static $langHostStateIs = null;
        protected static $langServices = null;
@@ -285,11 +288,8 @@ class NagiosHost extends NagVisStatefulObject {
                                        * The current child is member of the 
filter group, it declares 
                                        * itselfs as remaining object
                                        */
-                               if(in_array($OBJ->getName(), $arrAllowedHosts)) 
{
+                               if(in_array($OBJ->getName(), $arrAllowedHosts))
                                        $selfRemain = 1;
-                               } else {
-                                       $selfRemain = 0;
-                               }
                                
                                /**
                                        * If there are child objects loop them 
all to get their remaining
@@ -301,15 +301,14 @@ class NagiosHost extends NagVisStatefulObject {
                                        
                                        if(!$selfRemain && $childsRemain) {
                                                $selfRemain = 1;
+                                               $OBJ->automapConnector = true;
                                        }
                                }
                                
                                // If the host should not remain on the map 
remove it from the 
                                // object tree
-                               if(!$selfRemain) {
-                                       // Remove the object from the tree
+                               if(!$selfRemain)
                                        unset($this->childObjects[$i]);
-                               }
                        }
                        
                        $remain |= $selfRemain;


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to