List unreachable IP networks

Here's a Smarts (aka IONIX) ASL script example that lists the unreachable IP sub networks in the AM/PM domain. By "unreachable" I mean that none of the IP address in the subnet can be pinged.

This shows the kind of thing that is possible with ASL with a simple walk of the AM/PM repository.

START { .. eol } do {
        // Iterate over the known IPNetwork objects..
        foreach netName (getInstances("IPNetwork")) {
                net = object(netName);          // get a reference to the IPNetwork object
                ips = net->ConnectedTo;         // get a list if IP objects it contains
                n_up = 0;                       // initialize a couple of counters
                total = 0;

                // Iterate over the IPs in the subnet
                foreach ip (ips) {
                        // dont consider any duplicate IPs we find
                        if (ip->CreationClassName == "DuplicateIP") {
                                continue;
                        }

                        total = total + 1;              // add one to the total count
                        status = "UNKNOWN";             // give status a default value
                        status = ip->Status?IGNORE;     // get the IP's status, and ignore errors
                        if (status == "RESPONSIVE") {   // if the IP was pingable, add one to n_up
                                n_up = n_up + 1;
                        }
                }

                // if the network wasnt empty, but none of it's ips were pingable then 
                // output it's address and mask.
                if (total >= 1 && n_up == 0) {
                        print(net->NetworkNumber."|".net->Netmask);
                }
        }
}
Scroll to Top