solved & new nxsl script: multiple objects representing single device

Started by meshnet, November 11, 2018, 04:46:43 AM

Previous topic - Next topic

meshnet

Hello,

I have physical devices found through network discovery. The main issue is multiple objects are created. The device may have 10 interfaces with 10 different subnets. The result is 10 objects. This is detrimental at scale. The impact is now SNMP Polling and NetXMS Database, Severe Events and so on, are now 10 times in size. Of the thousands of devices, it is now ~5 thousand the impact.

I assume the method of preventing this is adding a NetXMS script to match device name to an existing device name. Is this an efficient way to go about this? Also, is there a way to clean up it's current state (thousands of devices) -- I am thinking I will write a NetXMS + Python script to determine if the nodes are duplicate, are not on a map, and are not holding any custom attributes I may have set. But.. Easier the better, no?

Suggestions, thoughts much appreciated.

Attached is a screenshot of the "issue" -- though, it may not be considered one by some or many admins here.

Kind regards,

-w

Victor Kirhenshtein

Hi,

are they duplicated within single subnet? If yes, can you please share screenshots of "Overview" and "Interfaces" tabs for few such devices?

Best regards,
Victor

meshnet

Good day Victor,

Quoteare they duplicated within single subnet? If yes, can you please share screenshots of "Overview" and "Interfaces" tabs for few such devices?

So the first thing I should point out is the container 'Entire Network' has never existed. I'm fairly certain it was removed for a specific reason. Perhaps it was removed from the database. I don't know how it was done, but I'd like more information as to how it was removed and if possible, I beg of you, any issues this may be causing.

Thanks for any help/thoughts on this.

Notes
- interface alerts (expected state UP or DOWN and IGNORE) are tagged on discovery with script: Hook::ConfigurationPoll
- in interfaces, the z_icmp_... interface is the devices primary (shortest-path) uplink, alert focus is for these ports/addresses
- if z_icmp... is down, the object turns RED but may be accessible over other networks (mesh topology w/ ospf)
- object-id are different for tentcity-1 and tentcity-2, yet, it is the same device.

Meta-Notes
- I've been upgrading the daemon and migrating it's database for ~3 years and not a single hiccup.
- Keep on kicking ass!


meshnet

Well, the post pretty much answers itself. Without an 'entire network' object/container, all nodes end up being bound/binded to Infrastructure Services.

So... Also wrote a script (first draft, you should optimize this or add it to another Hook:: script for efficiency) to block unwanted auto-discovery networks. This tremendously helps anyone create Layer-3 IP generated NetXMS Maps by removing 'common' subnets such as 192.168.88.1 or 192.168.20.1 or 169.254.0.1 etc..

So Here's the script, it does a few simple things but most importantly removes any 'unwanted' networks from the 'Entire Networks' container/zone

How can this script be improved? Should it exist in configuration? Or in Hook::AddNode? (is that it?)

It's been hand edited/cleaned up, and untested.. so please don't run this on production without reviewing everything it does.



sub main()
{

    $logo = "Hook::ConfigurationPoll ";
    trace(1, $logo . "Review and Edit this hook script dummy!");
    return;
    //
    // Rename if Null (For say, Netonix PoE switches)
    //
    if (($node->snmpSysName != null) && ($node->snmpSysName != "")) {
      if ($node->name != $node->snmpSysName) {
        RenameObject($node, $node->snmpSysName);
      }
    }

    //
    // Shut SNMP polling off for Agents, and vice versa.
    //
    if ($node->isAgent == 1) {
      $node->enableSnmp(false);
    } else if ($node->isSNMP == 1) {
      $node->enableAgent(false);
    }

    $only_allow_example_address = "10.69.0.0";
    $only_allow_example_subnet  = "255.252.0.0";

    interfaces = GetNodeInterfaces($node);

    foreach(iface : interfaces) {

        addrList = iface->ipAddressList;
        //
        // Nuke interfaces which do not have an IP address. Some devices may have 4,000 VLANs created by default.
        //
        if ((addrList[0] == null) && (iface->status == managed_status_code)) {
            trace(1, $logo . "(" . string($node->name) .") No IP addresses on interface -- UNMANAGED: " . string(iface->name) );
            UnmanageObject(iface);
        }

        $i = 0;
        foreach(ip : addrList) {
          $i = $i + 1;

          trace(1, $logo . "addrList[" . iface->name ."]:: " . $node->name . " - #". $i ." ". ip->address);

          $is_example_address_valid = AddrInSubnet(ip->address, $only_allow_example_address, $only_allow_example_subnet);

          if ($is_example_address_valid == false) {

              trace(1, $logo . "Unwanted ip address found: " . ip->address);
              parents = GetNodeParents($node);
           
              foreach(p : parents) {
                if (p->type == 1) {

                  $is_node_subnet_valid = AddrInSubnet($ipAddr, $only_allow_example_address, $only_allow_example_subnet);
                  $is_example_address_valid = AddrInSubnet(ip->address, $only_allow_example_address, $only_allow_example_subnet);
     
                  //
                  // While iterating, we stumbled on and are now removing: Unwanted Subnet in Object: " . p->name . " @ id #" . p->id . " (" . p->type . ")" );
                  //
                  if ($is_example_address_valid == false) {
                    DeleteObject(FindObject(p->id));
                  }

                  //
                  // Found exact and unwanted Subnet in Object: " . p->name . " @ id #" . p->id . " (" . p->type . ")" );
                  //
                  $this_ip_in_subnet_object = AddrInSubnet(ip->address, p->ipAddr, "255.0.0.0");
                  if ($this_ip_in_subnet_object) {
                    //
                    // This is where you can run p->setExcludeFromTopology(true);
                    //
                    DeleteObject(FindObject(p->id));
                  }


                } // end if: (type == subnet)
              } // end of foreach: parents->GetNodeParents(node)
          }
        } // end foreach: iface->ipAddressList


    } // end foreach GetNodeInterfaces

} // end Main