NetXMS Support Forum

English Support => General Support => Topic started by: David Jesus on March 22, 2018, 02:17:56 PM

Title: Deleting Objects interfaces
Post by: David Jesus on March 22, 2018, 02:17:56 PM
Hi, I am new to this program and I started using it for 3 weeks on an database already build from the previous internee, my colleagues want me to delete the interfaces that don't exist from the switches but every time I delete it comes back is there a way to only make the program show the ports that exist.
Title: Re: Deleting Objects interfaces
Post by: StanHubble on March 22, 2018, 03:29:24 PM
To limit the (re)addition of unwanted interfaces there is a script in the scriptlibrary called Hook::CreateInterface

There are some examples on the site here, but simply you can do:

if ($1->name ilike "Po1"){
   return false;
   }
return true;

Replace Po1 with the interface name that your switch is reporting.
Title: Re: Deleting Objects interfaces
Post by: David Jesus on March 23, 2018, 06:38:10 PM
Thx Stan, I used your example, I changed it to help me but the problem is that the ports are still coming back.
I want the ports fa1 to fa8 to but I does not work.
I am using this script:
if ($1->name ilike "*fa.*"){
      return false;}

return true;
Title: Re: Deleting Objects interfaces
Post by: StanHubble on March 23, 2018, 06:56:49 PM
Yeah I tried wildcards too.....didn't work.
Ugly, but I ended up with a if( ){} structure for each interface name that i didn't want and that worked.
(elminated about 9600 interfaces)
Title: Re: Deleting Objects interfaces
Post by: David Jesus on March 23, 2018, 07:13:25 PM
Looks that I have to do the same, thx again for the help.
Title: Re: Deleting Objects interfaces
Post by: Tursiops on March 24, 2018, 12:55:01 PM
The following should actually work:
if ($1->name ilike "*fa*") { return false;}
return true;

Note that that your code was comparing to "*fa.*"

You could also use:
if ($1->name imatch "fa") { return false;}
return true;
Title: Re: Deleting Objects interfaces
Post by: David Jesus on March 27, 2018, 12:11:59 PM
Thx Tursiops the code works!
Title: Re: Deleting Objects interfaces
Post by: JayST on August 18, 2019, 12:27:54 AM
I also resolved the (re)addition issue using the Hook::CreateInterfaces script and filter some names there, but what would be the easiest way to remove the unwanted interfaces across a bunch of nodes that got added before filtering?
Title: Re: Deleting Objects interfaces
Post by: Tursiops on August 18, 2019, 07:12:33 AM
You could write a script to go through all devices, enumerate the interfaces and utilise the DeleteObject function in NXSL to remove the interfaces. Or you could add the interface enumeration and delete to the configuration poll hook.
Title: Re: Deleting Objects interfaces
Post by: JayST on August 18, 2019, 10:33:00 AM
Ok thanks.
About running such one-time scripts:
Would i need to create a script in the script library and run it in the debug console with exec command? Or is there a easier "run this script now" functionality?
Title: Re: Deleting Objects interfaces
Post by: Tursiops on August 18, 2019, 01:52:37 PM
You can right-click on any node to execute a server script (I'm assuming that's what you mean as debug console?) and just write your code in there. Your code wouldn't be node specific (if you are indeed enumerating all nodes and then all interfaces per node) so it doesn't matter against which node you run it. Or you could write it in the script library and then select it from the drop down. Or you could schedule a task that runs a script from the script library.
Title: Re: Deleting Objects interfaces
Post by: JayST on August 19, 2019, 12:07:19 AM
that sums it up quite good! great stuff, thanks.
with debug console i actually meant the server console from the Tools menu.