NetXMS Support Forum

English Support => General Support => Topic started by: nichky on March 11, 2026, 07:08:32 AM

Title: Filtering MikroTik Devices by IP Address Instead of Vendor
Post by: nichky on March 11, 2026, 07:08:32 AM
Hi

I'm currently using the following condition to collect all MikroTik devices:

return $node->vendor == "MikroTik";

Is there any way to perform this per IP address instead?
Title: Re: Filtering MikroTik Devices by IP Address Instead of Vendor
Post by: Alex Kirhenshtein on March 12, 2026, 12:56:14 PM
$node.ipAddr (string)

or $node.ipAddress (instance of InetAddress): https://netxms.org/documentation/nxsl-latest/#class-inetaddress
Title: Re: Filtering MikroTik Devices by IP Address Instead of Vendor
Post by: nichky on March 13, 2026, 03:54:43 AM
$subnet = InetAddress("x.y.z.0")
$mask = 24

if ($node.ipAddress.isInSubnet($subnet, $mask)) {
    return 1;  // match
} else {
    return 0;  // no match
}



I got this, but it's not working. Can you please modify it?
Title: Re: Filtering MikroTik Devices by IP Address Instead of Vendor
Post by: Filipp Sudanov on April 07, 2026, 03:59:51 PM
First of all two first lines should end with ; char.
There is no isInSubnet() method on InetAddress class, but there is contains() method on subnet, so we should go opposite way and check it on the subnet, there's an example here: https://netxms.org/documentation/nxsl-latest/#_instance_methods_18
So, modifying your code:

subnetObject = InetAddress("192.168.56.0", 24);

if (subnetObject.contains($node.ipAddress)) {
    return 1;  // match
} else {
    return 0;  // no match
}
Title: Re: Filtering MikroTik Devices by IP Address Instead of Vendor
Post by: Victor Kirhenshtein on April 07, 2026, 04:06:01 PM
And just for completeness, script above can be simplified to
return InetAddress("192.168.56.0", 24).contains($node.ipAddress);