Deleting Objects interfaces

Started by David Jesus, March 22, 2018, 02:17:56 PM

Previous topic - Next topic

David Jesus

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.

StanHubble

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.

David Jesus

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;

StanHubble

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)

David Jesus

Looks that I have to do the same, thx again for the help.

Tursiops

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;

David Jesus


JayST

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?

Tursiops

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.

JayST

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?

Tursiops

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.

JayST

#11
that sums it up quite good! great stuff, thanks.
with debug console i actually meant the server console from the Tools menu.