nagvis icon indicating copy to clipboard operation
nagvis copied to clipboard

Worldmap - not possible to use multiple worldmaps with their own source-files

Open kafos opened this issue 6 years ago • 13 comments

it is not possible to create a second worldmap with a different .db file. The next created map has the same hosts like first one. It should be possible to create worldmaps with different sources

kafos avatar Dec 20 '17 14:12 kafos

The idea behind the worldmap was that each object has always only a single position on the planet and will not be on another position at the same time. That should also be true for you, right?

What do you want to archieve with such a change?

LarsMichelsen avatar Jan 07 '18 10:01 LarsMichelsen

In our company we use the worldmap to map our network connections. Multiple maps (or multiple layers) would make sense, e.g. our DSL and directional radio antennas (dt. Richtfunkantennen) could be separated (= looks clearer).

Dennis14e avatar Mar 19 '18 06:03 Dennis14e

@LarsMichelsen in our company we have different kind/category of host, which should be displayed in different worldmaps. And this is not possible now because everything is on one map. It would be really nice if you can implement the possibility to choose a config/db-file where the map is storing the data.

kafos avatar Apr 03 '18 19:04 kafos

Yes, I am in the same situation. My company needs to have one map per customer, we are monitoring different stations and we want to give every one a personal map where they can see the status of their services/hosts with one look. We are currently using Nagios 4.4.1 and out of ideas, I was very excited at first with this tool but for us it's just useless without the user-view map asigned to the hostsgroup that he owns. If someone is in the same situation or have any ideas, please let me know.

angelfoga avatar Aug 20 '18 12:08 angelfoga

@angelfoga and others.

To serve multiple customers one could install multiple instances of Nagvis all in their own directory.

T100D avatar Aug 21 '18 06:08 T100D

@T100D that is maybe just a workaround. It's just not making sense beeing able to create multiple worldmaps in one instance but not beeing able to use different config files for each map

kafos avatar Aug 21 '18 08:08 kafos

@kafos I agree, but it's a free tool and personally I don't know how hard would be to implement this. @T100D Thanks! I'll try this workaround, could be the solution for me.

Edit#1: As @kafos said, the problem is the nagvis.conf file... so this won't work. The file aims to just one path. By editing it the 2nd instance shows, but you can't see both at the same time.

angelfoga avatar Aug 22 '18 07:08 angelfoga

@LarsMichelsen Sorry, do you think that you will realize this enhancement until 2019?

HAlover99 avatar Oct 27 '19 12:10 HAlover99

If you add the objects to the map file rather than the db, they appear only on that map. Not as editable/dynamic but would allow you to have an object (like a datacenter) appear on every map but a different object only on specific maps.

ekrichbaum avatar Jan 03 '20 19:01 ekrichbaum

Hello!

Thank you for advice!

For use multiple worldmaps was modified PHP files GlobalMapCfg.php, worldmap.php.

The database name 'worldmap.db' has been changed to "worldmap-$mapnamedb.db".

/usr/local/nagvis/share/server/core/classes# diff -u GlobalMapCfg-ORIGINAL GlobalMapCfg.php
    public function __construct($name = '', $isView = true) {
         $this->name = $name;
         $this->isView = $isView;

+// Modifited for use multiple worldmaps with their own source DB files
+       global $mapnamedb;
+       $mapnamedb = $name;
         if(self::$validConfig == null)
             $this->fetchValidConfig();
/usr/local/nagvis/share/server/core/sources# diff -u worldmap-ORIGINAL worldmap.php

 function worldmap_init_db() {
-    global $DB;
+    global $DB, $mapnamedb;
     if ($DB !== null)
         return; // only init once
     $DB = new CorePDOHandler();
-    if (!$DB->open('sqlite', array('filename' => cfg('paths', 'cfg').'worldmap.db'), null, null))
+    // Modifited for use multiple worldmaps with their own source DB files
+//    if (!$DB->open('sqlite', array('filename' => cfg('paths', 'cfg').'worldmap.db'), null, null))
+    if (!$DB->open('sqlite', array('filename' => cfg('paths', 'cfg')."worldmap-$mapnamedb.db"), null, null))
         throw new NagVisException(l('Unable to open worldmap database ([DB]): [MSG]',
             Array('DB' => $DB->getDSN(),
                   'MSG' => json_encode($DB->error()))));
 }

 function changed_worldmap($MAPCFG, $compare_time) {
-    $db_path = cfg('paths', 'cfg').'worldmap.db';
+// Modifited for use multiple worldmaps with their own source DB files
+//    $db_path = cfg('paths', 'cfg').'worldmap.db';
+    global $mapnamedb;
+    $db_path = cfg('paths', 'cfg')."worldmap-$mapnamedb.db";
+
     return !file_exists($db_path) || filemtime($db_path) > $compare_time;
 }
ls -l | grep worldmap
 worldmap-GPON_clients.db
 worldmap-Magistr_SPD.db
 worldmap-Raspred_SPD.db
 worldmap-Telephony.db

neperpbl3 avatar Nov 04 '21 18:11 neperpbl3

That's actually pretty slick. If you don't use the db have have a cfg file you could probably have your objects unique as well, but this is more elegant.

ekrichbaum avatar Nov 07 '21 16:11 ekrichbaum

The approach is hacky, but you may want to clean it up a bit and send a push request. I'd be happy to add it. One suggestion would be to hand over $map_name from the call sites of worldmap_init_db() as argument instead of using the global variable $mapnamedb.

A more minimalistic approach would be to add a mode where the worldmap coordinates are read from the map configuration as normal attributes, but that would require more changes.

LarsMichelsen avatar Nov 26 '21 20:11 LarsMichelsen

. I'd be happy to add it.

I'm not a programmer. I did everything I could. Please add the correct method. This is a very necessary extension.

Please!!!

neperpbl3 avatar Jan 10 '22 09:01 neperpbl3