Module: nagvis Branch: master Commit: 1ed452e410e49b35a37b423b9278f314ae161baf URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=1ed452e410e49b35a37b423b9278f314ae161baf
Author: Lars Michelsen <[email protected]> Date: Tue Oct 20 23:02:11 2009 +0200 #22 Automap to automap links are now possible; See sample automap for details --- etc/automaps/__automap.cfg | 40 ++++++++++++++++++++++-- share/server/core/classes/NagVisAutoMap.php | 26 +++++++++++++++ share/server/core/classes/NagVisAutomapCfg.php | 10 +++--- 3 files changed, 68 insertions(+), 8 deletions(-) diff --git a/etc/automaps/__automap.cfg b/etc/automaps/__automap.cfg index fec70d9..53459ec 100644 --- a/etc/automaps/__automap.cfg +++ b/etc/automaps/__automap.cfg @@ -10,13 +10,47 @@ label_show=1 label_border=transparent } +################################################################################ +# Dummy host object +################################################################################ +# # When you like to modify the url of all host objects you need to define a # dummy host object. The dummy host object may contain the options you # can't define in the global section (like url). # +# The dummy host MUST be the first host defined in the automap configuration +# file. +# +# The settings of the first host will be used for all objects on the map. +# The coords x/y need to be set but will be ignored on the automap. +# +define host { +host_name=__dummy__ +x=0 +y=0 +url=[htmlcgi]/status.cgi?host=[host_name] +} + +################################################################################ +# Custom object settings +################################################################################ +# +# This is a sample for an automap to automap link. With this and the different +# automap configuration files which are allowed since NagVis 1.5 you can realize +# dril down navigations through your parent structure. +# +# The configuration is matched by the host_name. When the automap __automap is +# called and the host with the name www2.nagvis.org should be rendered on the +# map the automap takes a look in the configuration file if there are some +# options defined for a host with this name. When it finds a host it reads all +# configuration options and uses them to render the object on the automap. +# +# The coords x/y need to be set but will be ignored on the automap. +# #define host { -#host_name=dummy +#host_name=www2.nagvis.org #x=0 #y=0 -#url=[htmlcgi]/status.cgi?host=[host_name] -#} +#iconset=std_big +#url=[htmlbase]/frontend/nagvis-js/index.php?mod=Automap&act=view&show=__automap&root=www2.nagvis.org&maxLayers=2&renderMode=undirected +#} \ No newline at end of file diff --git a/share/server/core/classes/NagVisAutoMap.php b/share/server/core/classes/NagVisAutoMap.php index 436e821..635d95b 100644 --- a/share/server/core/classes/NagVisAutoMap.php +++ b/share/server/core/classes/NagVisAutoMap.php @@ -158,6 +158,8 @@ class NagVisAutoMap extends GlobalMap { $this->filterChildObjectTreeByGroup(); } + $this->loadObjectConfigurations(); + // Create MAPOBJ object, form the object tree to map objects and get the // state of the objects $this->MAPOBJ = new NagVisMapObj($this->CORE, $this->BACKEND, $this->MAPCFG); @@ -444,6 +446,30 @@ class NagVisAutoMap extends GlobalMap { # END Public Methods # ##################################################### + private function loadObjectConfigurations() { + // Load the hosts from mapcfg into the aConf array + $aConf = Array(); + $aHosts = $this->MAPCFG->getDefinitions('host'); + foreach($aHosts AS $aHost) { + $aConf[$aHost['host_name']] = $aHost; + } + + // #22 FIXME: Need to add some code here to make "sub automap" links possible + // If a host matching the current hostname ist available in the automap configuration + // load all settings here + + // Loop all map object + foreach($this->arrMapObjects AS $OBJ) { + // Try to find a matching object in the map configuration + if(isset($aConf[$OBJ->getName()])) { + unset($aConf[$OBJ->getName()]['type']); + unset($aConf[$OBJ->getName()]['object_id']); + unset($aConf[$OBJ->getName()]['host_name']); + $OBJ->setConfiguration($aConf[$OBJ->getName()]); + } + } + } + /** * Do the preflight checks to ensure the automap can be drawn */ diff --git a/share/server/core/classes/NagVisAutomapCfg.php b/share/server/core/classes/NagVisAutomapCfg.php index caed45c..7ee93ad 100644 --- a/share/server/core/classes/NagVisAutomapCfg.php +++ b/share/server/core/classes/NagVisAutomapCfg.php @@ -62,17 +62,17 @@ class NagVisAutomapCfg extends GlobalMapCfg { public function &getObjectConfiguration() { $objConf = Array(); - // Get object configuration from configuration file + /* + * Get object default configuration from configuration file + * The dummy host MUST be the first host defined in the automap configuration file. + * The settings of the first host will be used for all objects on the map + */ foreach($this->getValidTypeKeys('host') AS $key) { if($key != 'type' && $key != 'backend_id' && $key != 'host_name' & $key != 'object_id') { $objConf[$key] = $this->getValue('host', 0, $key); } } - // #22 FIXME: Need to add some code here to make "sub automap" links possible - // If a host matching the current hostname ist available in the automap configuration - // load all settings here - return $objConf; } } ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
