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