NetXMS Support Forum

English Support => General Support => Topic started by: Dani@M3T on July 06, 2015, 05:31:20 PM

Title: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 06, 2015, 05:31:20 PM
I have a Layer3 map where I only want nodes from container 'London'.

I tried with the following filter script but got always all nodes instead of only those in container 'London':

parents = GetNodeParents((FindObject($1));
if (parents == null) return false;
foreach(p : parents)
{
   if (p->type == 5 && p->name == "London") return true;
}
return false;



Thanks for any input!
Title: Re: Object Filter in Layer3-Maps
Post by: tomaskir on July 06, 2015, 07:03:00 PM
1) use $object variable, not $1
2) yes, its an "NetObj" class object
3) sounds like a bug, log it in bug-tracker :)
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 06, 2015, 07:37:11 PM
Thanks for your fast reply Tomas.

using $object instead of $1 -> Error 17 (Argument is not of string type and cannot be converted to string. So I changed to
parents = GetNodeParents($object);
-> Error 21 (Bad or incompatible object class), it's NetObj not Node class. So I tried this (most logical for me):
parents = GetObjectParents($object);
No error, but now the map is empty :-(

I registered a ticket for the disable-bug

thanks
Dani
Title: Re: Object Filter in Layer3-Maps
Post by: tomaskir on July 06, 2015, 07:57:23 PM
This works for me:
parents = GetObjectParents($object);

foreach(p : parents)
{
   if (p->type == 5 && p->name == "Something") return true;
}
return false;


Two things to note:
1) it only takes "direct" parents of the node, its not upwards recursive, so doesnt take parents of the node's parents into account
2) CheckTrustedNodes (or equivalent security) will need to be correctly set

You can run the script directly on an object using "Execute server script" to check whats going on.
I suggest adding this into the foreach loop to make debug easier:
println("Type: " . p->type . " Name: " . p->name);
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 07, 2015, 08:44:26 PM
when I set sever variable 'CheckTrustedNodes' to 0 (and restart the NetXMS server of course), I get the nodes on the map. But I get no connectors on the map beside VPN-connectors. Why? Connectors are no NetObj objects.... so no filtering on that. Is this the same on your installation?

I don't understand exactly why 'CheckTrustedNodes' has an influence here.
But when I set all nodes in a container to the Trusted Nodes of this container, this nodes appear on the map.

Thanks for the hint with the 'direct' parents.
Title: Re: Object Filter in Layer3-Maps
Post by: tomaskir on July 08, 2015, 11:20:14 AM
I do not know why script security is being applied here, maybe Victor can tell us. :)

You are not getting connectors as in the links connecting the nodes on the map?
I get those when using the filtering script.
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 08, 2015, 01:13:25 PM
Yes maybe Victor can give an answer.

I only see one VPN connector but no other 'normal' connectors. See the attached printscreen. Strange. All nodes on the left side should be connected to one of the VPN endpoints and the two on the right side with the other. In the map without the filtering script all connectors are there
Title: Re: Object Filter in Layer3-Maps
Post by: tomaskir on July 08, 2015, 01:33:49 PM
As I mentioned, for me it works fine with filtering scripts, but I do not show end-nodes on my map.

Victor will have to shed more light on both the issues :)
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 08, 2015, 01:54:46 PM
Thanks Tomas for your help.

Now I hope Victor will see this thread soon.

Dani
Title: Re: Object Filter in Layer3-Maps
Post by: Victor Kirhenshtein on July 08, 2015, 04:46:44 PM
Hi,

links are not affected by map filter. Did you layout nodes by hand? If not, it seems as if links are there but just invisible. Just in case - check link color in map properties.

Best regards,
Victor
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 08, 2015, 04:55:27 PM
Hi Victor

I tried manually and automatic layout. At the moment it's automatic layout. On this map are routers, switches and end nodes.

Can you please also explain for short the trusted nodes in this situation (not in general).

thanks
Dani
Title: Re: Object Filter in Layer3-Maps
Post by: Victor Kirhenshtein on July 08, 2015, 05:00:43 PM
currently all scripts are handled equally - so it doesn't matter if script is a network map filter or DCI transformation script for example. Reason is the same - imagine you have access only to network map object - if script do not have access checks you'll be able to access data for nodes you don't have access to. I thinking for some time already about more sophisticated access control within scripts, but don't have better solution yet.

Best regards,
Victor
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 08, 2015, 05:03:08 PM
ok, thanks for the explanation.

But do you have any idea why all connectors are missing on the filtered layer3 map?
Title: Re: Object Filter in Layer3-Maps
Post by: Victor Kirhenshtein on July 08, 2015, 05:28:18 PM
Did you check connector color in map properties? By objects' locations it seems that they are connected but connectors are invisible.

Best regards,
Victor
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 08, 2015, 05:34:34 PM
Default connection options are on default color. I also tried with manually set to black. VPN-connectors (dotted) and the 'normal' connectors always have the same color. The last printscreen was without automatic layout. Here is one with automatic layout. Here I can't see any arrangement. Everything is mixed up.
Title: Re: Object Filter in Layer3-Maps
Post by: Victor Kirhenshtein on July 08, 2015, 08:14:43 PM
I probably understand it - nodes on L3 map re connected via subnet objects, not directly - and you filtered out subnet objects. You should change your filter to allow subnets or add relevant subnet objects to your container.

Best regards,
Victor
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 08, 2015, 10:51:35 PM
Hi Victor

When I add the subnets to the containers, I got the connectors in Layer3 map. But that's not very elegant. The other solution seems to be better.
How can I change my filter to allow the necessary subnet objects?

My current filter script is this:
parents = GetObjectParents($object);
//if (parents == null) return false;
foreach(p : parents)
{
   if ((p->type == 5) && (p->name == "containerA" || p->name == "ContainerB")) return true;
}
return false;
Title: Re: Object Filter in Layer3-Maps
Post by: Victor Kirhenshtein on July 08, 2015, 10:55:03 PM
Hi,

it could be like this:


if ($object->type == 1)
   return true;  // allow all subnets

parents = GetObjectParents($object);
//if (parents == null) return false;
foreach(p : parents)
{
   if ((p->type == 5) && (p->name == "containerA" || p->name == "ContainerB")) return true;
}
return false;


You can also add additional contraints on subnet names as usual using $object->name.

Best regards,
Victor
Title: Re: Object Filter in Layer3-Maps
Post by: Dani@M3T on July 09, 2015, 02:55:12 PM
All my subnets has names like '10.1.17.0/24 (SiteA)' and all Containers are named like 'SiteA'. So I can filter like this:
// only Subnets with 'SiteA' oder 'SiteB' in name
if (($object->type == 1) && (($object->name ~= ".*(SiteA.*)") || ($object->name ~= ".*(SiteB.*)")))
   return true;


Now the filtered map looks ok! But...

...only one new problem. Cluster nodes:
I tried to make an extention of the filtering script to handle clusters. But I found with a test script that cluster nodes has no node parents.

parents = GetObjectParents($object);
foreach(p : parents)
   println("Type: " . p->type . " Name: " . p->name);

Is this by design? With 'GetObjectParents' function I get neither the cluster-object nor the container as parent object. So all clusters nodes are missing on filtered maps.