I think you'll find that calculating this at the SQL level is your best option. You can easily get the IP addresses of resources from the Inv_AeX_AC_TCPIP table. This comes with basic inventory on a computer. If your solution isn't adding resource information to this table, I'd suggest you either start adding the data or create a new data class that is smaller to hold this information for your resources.
Either way, once you have this information in a table it's just a matter of joining against another table or two to get your list. That's really something SQL is made for. Plus, using a standard filter and resource target on this will mean you get security automatically.