<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Instance Filter Script with Net.InterfaceNames list]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I am trying to filter out interfaces which are adminState down as well as expectedState down via instance filter scripting.<br />
I'm using the Net.InterfaceNames Agent List to get a proper name for the DCI itself and am having issues retrieving those interface states in the filter script.<br />
As $1 is only the interface name, I used the FindObject function hoping to get the interface object to then allow me to check for adminState and expectedState.<br />
Unfortunately that didn't work out, so I tried GetInterfaceObject, but that requires an interface index - which I don't get with the Net.InterfaceNames list.<br />
Switching to Net.InterfaceList didn't help me either.</p>
<p dir="auto">Does anyone have a code snippet to point me in the right direction?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.netxms.org/topic/4575/instance-filter-script-with-net.interfacenames-list</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:35:40 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4575.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Jul 2016 22:52:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Tue, 19 Jul 2016 06:54:56 GMT]]></title><description><![CDATA[<p dir="auto">As the node on FindObject does not limit the search scope, I implemented this using the suggested GetNodeInterfaces loop. Works fine. <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://forum.netxms.org/post/20437</link><guid isPermaLink="true">https://forum.netxms.org/post/20437</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Tue, 19 Jul 2016 06:54:56 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Mon, 18 Jul 2016 09:24:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">node object in FindObject call is not for limiting search scope, but for access control (it will only find objects where this node set as trusted if trusted nodes check is on). If you have trusted nodes check off, you can pass null as node parameter.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/20428</link><guid isPermaLink="true">https://forum.netxms.org/post/20428</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Mon, 18 Jul 2016 09:24:56 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Fri, 08 Jul 2016 05:28:39 GMT]]></title><description><![CDATA[<p dir="auto">Hi Victor,</p>
<p dir="auto">If I use FindInterfaceByName, I would have to loop through all interfaces on the node for each individual interface I want to instance (as per your code). If I have a switch stack of 96 ports or more, that would cost some resources every time an instance discovery is running. I was hoping that if I can use FindObject instead and provide the $node as per documentation, i.e. FindObject($1,$node), that should not be a global search and avoid the loops?<br />
Guess I'll wait for 2.0.5 and see if I can get it to work with that. Otherwise I'll be looping. <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">Cheers</p>
]]></description><link>https://forum.netxms.org/post/20386</link><guid isPermaLink="true">https://forum.netxms.org/post/20386</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Fri, 08 Jul 2016 05:28:39 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Thu, 07 Jul 2016 08:24:21 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">yes, it is bug in FindObject (fixed in 2.0.5). Anyway, it may not be a good idea to use FindObject - because it finds objects globally, while you need interfaces from that specific node. You can add the following function to your script to get interface by name:</p>
<pre><code>sub FindInterfaceByName(node, ifName)
{
	foreach(i : GetNodeInterfaces(node))
	{
	   if (i-&gt;name == ifName)
	      return i;
	}
	return null;
}
</code></pre>
<p dir="auto">and use it like this:</p>
<pre><code>iface = FindInterfaceByName($node, "Se1/0");
</code></pre>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/20349</link><guid isPermaLink="true">https://forum.netxms.org/post/20349</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Thu, 07 Jul 2016 08:24:21 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Tue, 05 Jul 2016 13:33:47 GMT]]></title><description><![CDATA[<p dir="auto">Sorry, but that does not work for me either.<br />
If I use Net.InterfaceNames as list for InstanceDiscovery, I receive an error that I am not using a whole number in GetInterfaceObject(). That's expected, as it requires the interface index, not the name.<br />
If I use Net.InterfaceList instead, I get the same error and a whole number of DCIs with names like "1 127.0.0.1/8 24(2147483647) 000000000000 Loopback Pseudo-Interface 1" (that's just the {instance} part of it, which appears to mix index, IP addresses and MAC address).</p>
<p dir="auto">If I use FindObject, for all I can tell I should be getting an interface object.<br />
After going through some older forum posts I thought I'd test that as follows:</p>
<pre><code>i = FindObject($1,$node);
trace (0,i-&gt;name);
trace (0,classof(i));
</code></pre>
<p dir="auto">The logs then give me the interface name and "NetObj" in the logs.<br />
That also explains why none of the interface attributes (short of the NetObj ones) were accessible - I got the wrong object type back. Based on the documentation I would have thought this should be "Interface"?</p>
]]></description><link>https://forum.netxms.org/post/20331</link><guid isPermaLink="true">https://forum.netxms.org/post/20331</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Tue, 05 Jul 2016 13:33:47 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Tue, 05 Jul 2016 06:46:10 GMT]]></title><description><![CDATA[<p dir="auto">Well,<br />
i found this little trick along some other stuff. This should provide everything you need.</p>
<pre><code>i = GetInterfaceObject($node, $1);
if ((i != null) &amp;&amp; (i-&gt;expectedState == 0))
{
	return %(true, $1, i-&gt;description);
}
return false;
</code></pre>
]]></description><link>https://forum.netxms.org/post/20330</link><guid isPermaLink="true">https://forum.netxms.org/post/20330</guid><dc:creator><![CDATA[user55116]]></dc:creator><pubDate>Tue, 05 Jul 2016 06:46:10 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Mon, 04 Jul 2016 21:13:43 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the snippet.</p>
<p dir="auto">Not sure how well this would work inside of an instance filter script.<br />
Instance Discovery will loop through the list of all interfaces and return the names, one by one. It's inside that loop that the instance filter script runs (for all I understand).<br />
I guess I could loop through all node interfaces for each interface on the node discovered by Instance Discovery, then compare names and on a match check the expectedState. Seems a bit inefficient though. If I could directly retrieve the correct interface object from within the instance filter script, it would be a fairly quick check.</p>
<p dir="auto">From what I read about FindObject, that should have worked using the interface name provided by Instance Discovery.  But I could not use any of the object's properties afterwards.  ???<br />
I might give it another go later today and provide the code I used. Maybe I've had some typo or logic error in there - wouldn't be the first time.  :-[</p>
]]></description><link>https://forum.netxms.org/post/20327</link><guid isPermaLink="true">https://forum.netxms.org/post/20327</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Mon, 04 Jul 2016 21:13:43 GMT</pubDate></item><item><title><![CDATA[Reply to Instance Filter Script with Net.InterfaceNames list on Mon, 04 Jul 2016 06:27:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">this is a part of my ConfigPoll hook, which is looking for expectedState of an interface. Maybe this will help you.</p>
<pre><code>interfaces = GetNodeInterfaces($node);
foreach(i : interfaces) {
	if(i-&gt;expectedState == 0) {	// 0 = UP, 1 = DOWN, 2 = IGNORE
		...
	}
	else {
		...
	}
}
</code></pre>
]]></description><link>https://forum.netxms.org/post/20314</link><guid isPermaLink="true">https://forum.netxms.org/post/20314</guid><dc:creator><![CDATA[user55116]]></dc:creator><pubDate>Mon, 04 Jul 2016 06:27:14 GMT</pubDate></item></channel></rss>