NetXMS Support Forum

English Support => General Support => Topic started by: sjudy on April 03, 2019, 03:40:57 AM

Title: Question about discovery w/ filter
Post by: sjudy on April 03, 2019, 03:40:57 AM
Hello,

I am new to writing scripts for discovery and have that down ok... but I am looking for a way to also filter the interfaces if they are not active.

In this case, I have a sonicwall I wish to monitor, but I don't need to see all the ports not in use.  They all show UP because they use PortShields which connect all the ports in an UP fashion, so I wanted to filter on MTU which in SNMP shows zero on all the ports I wish to ignore.

My SNMP DCI looks like this:

Param: .1.3.6.1.2.1.31.1.1.1.10.{instance}
Discovery (OID): .1.3.6.1.2.1.2.2.1.1

Discovery Filter:
transport = CreateSNMPTransport($node);
if (transport == null)
return false;

// get the interface name to return as instance-name
vb = SNMPGet(transport, ".1.3.6.1.2.1.31.1.1.1.1." . $1);
if (vb == null)
return false;

// filter out loopback
if (vb->value == "lo")
return false;

return %(true, $1, vb->value);


I know MTU is pulled in and stored with the interfaces, but not sure how to filter in the discovery script I have so far.

Like I said, pretty new at this and just getting my hands dirty.... so any help would be greatly appreciated!
Title: Re: Question about discovery w/ filter
Post by: Victor Kirhenshtein on April 03, 2019, 01:55:46 PM
Hi,

knowing interface index you can use function GetInterfaceObject($node, index) to get interface object, and then read it's property "mtu". Alternative approach could be to send SNMP request for .1.3.6.1.2.1.2.2.1.4.{instance} as you do for interface name.

Best regards,
Victor

Title: Re: Question about discovery w/ filter
Post by: sjudy on May 22, 2019, 05:04:46 AM
Sorry for my delay... I thought I responded.  Thank you! Worked perfectly!