<?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[Regex on Instance Discovery]]></title><description><![CDATA[<p dir="auto">Hi everyone,<br />
I was looking for a way to create a dci for network traffic on all interface address.<br />
I'm using a template and instance discovery for the process. Now I know that I can use the agent list "Net.InterfaceList" to get interface index and then with Net.Interface.BytesIn64({instance}) get the data I need.<br />
I use following Instance discovery filter script that Alex Kirhenshtein created:<br />
if ($1 ~= "^([0-9]+) .*")<br />
{<br />
       return %(true, $1); // at this point $1 contains first matching group<br />
}<br />
return false;</p>
<p dir="auto">I was trying to modify regex string to "^[0-9](?!.*127\.0\.0\.1)" to avoid loopback interface.<br />
But I get error "execution error: Error 18 in line 3: Invalid regular expression"<br />
As I couldn't find a way to do it, I use following script<br />
if ((index($1,"127.0.0.1/8")==0)&amp;&amp;(index($1,"::1/128")==0)&amp;&amp;(index($1,"fe80:")==0))<br />
{<br />
     if ($1 ~= "^([0-9]+) .*")<br />
     {<br />
          return %(true, $1); // at this point $1 contains first matching group<br />
     }<br />
}<br />
return false;</p>
<p dir="auto">Now it works but I tested my regex string on others apps and it worked fine.<br />
Also I was reading that with regex you can "split" the agent list string into multiple values, for example $1:iface Index, $2:IP Address, etc.<br />
although now is working, I'm a bit confuse about regex expressions on netxms. how could I do it the same I do but with regex?<br />
also, when you use regex to get multiple values from a string, how could you asign to multiple variables ($1,$2,etc)</p>
]]></description><link>https://forum.netxms.org/topic/5130/regex-on-instance-discovery</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:12:19 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/5130.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Jul 2017 18:32:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Regex on Instance Discovery on Wed, 19 Jul 2017 00:41:52 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Looks to me like negative lookahead regular expressions are not working (I tested a bit and got the same result you did).<br />
Not sure if there's some syntax difference or if the ?! is being interpreted by something else.</p>
<p dir="auto">You could change your</p>
<pre><code>if ($1 ~= "^([0-9]+) .*")
</code></pre>
<p dir="auto">to this</p>
<pre><code>if ( ($1 ~= "^([0-9]+) .*") &amp;&amp; ( ! ( $1 ~= "^[0-9]+ (127|::1|fe80).*" ) ) ) {
</code></pre>
<p dir="auto">It should work and remove the need for the additional if statement you added, but in the end, it's still just a workaround for the negative lookahead not working properly.</p>
<p dir="auto">Cheers</p>
]]></description><link>https://forum.netxms.org/post/22717</link><guid isPermaLink="true">https://forum.netxms.org/post/22717</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Wed, 19 Jul 2017 00:41:52 GMT</pubDate></item><item><title><![CDATA[Reply to Regex on Instance Discovery on Tue, 18 Jul 2017 20:31:23 GMT]]></title><description><![CDATA[<p dir="auto">Any Help?</p>
]]></description><link>https://forum.netxms.org/post/22714</link><guid isPermaLink="true">https://forum.netxms.org/post/22714</guid><dc:creator><![CDATA[lmontano]]></dc:creator><pubDate>Tue, 18 Jul 2017 20:31:23 GMT</pubDate></item></channel></rss>