<?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 discovery method: script]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm having troubles to get the instance-discovery by script working.</p>
<p dir="auto">I have:</p>
<ul>
<li>Instance Discovery Method: Script</li>
<li>a Filter script (in the moment just tracing)</li>
</ul>
<p dir="auto">However, the filter script doesn't get called - I assume the array returned by list_attributes_by_key() does not find it's way to the instance discovery.<br />
When running the script via "Execute server script", I get the debugs (trace, println) printed.</p>
<p dir="auto">Can someone point out my error with this ?</p>
<p dir="auto">Kind regards,<br />
Thomas</p>
<p dir="auto">edited: this is NetXMS 2.1M2</p>
<p dir="auto">Script "list_attributes_like_http"</p>
<pre><code>// Works!
// array a;
// a[0] = "Entry 1";
// a[1] = "Entry 2";
// return a;

use list_attributes;

a = list_attributes_by_key("http:.*");
foreach (entry: a)
	{
	msg = "like http: " . $node-&gt;name . " " . entry;
	trace(1, msg);
	println "P " . msg;
	}
return a;
</code></pre>
<p dir="auto">"list_attributes"</p>
<pre><code>// list_attributes
//
// retrieving attribute values.
//
//
// Parameter:
//		$1: regex to check the attribute key for.
//
// Returns:
//		List of all attributes matching the attribute

sub list_attributes_by_key(pattern)
	{
	array r;
	if (pattern == null)
		{
		msg = $node-&gt;name .  " list_attribute_by_key: no pattern!";
		println msg;
		trace(1, msg);
		return a;
		}
	test = "http://12345.678/";
	if (test match pattern)
		println "pattern: ". pattern . " test matched OK".

	r_i = 0;
	attr = $node-&gt;customAttributes;
	foreach (key: attr-&gt;keys)
		{
		println a;
		if (key ~= pattern)
			{
			println $node-&gt;name . " return key=" . key;
			r[r_i++] = key;
			}
		else
			{
			println $node-&gt;name . " no match for " . key . ". pattern=". pattern;
			}
		}
	return r;
	}
</code></pre>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000003486-netxms01.PNG" alt="netxms01.PNG" class="img-markdown  img-fluid" width="724" height="463" /></p>
]]></description><link>https://forum.netxms.org/topic/4963/instance-discovery-method-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 12:30:49 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4963.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Mar 2017 11:23:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Instance discovery method: script on Tue, 27 Jun 2017 21:07:02 GMT]]></title><description><![CDATA[<p dir="auto">Fixed in upcoming 2.1 release. DCI owner can be accessed in instance discovery and data collection scripts via $targetObject global variable.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/22547</link><guid isPermaLink="true">https://forum.netxms.org/post/22547</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 27 Jun 2017 21:07:02 GMT</pubDate></item><item><title><![CDATA[Reply to Instance discovery method: script on Sun, 02 Apr 2017 19:25:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I've added a feature request for that: <a href="https://track.radensolutions.com/issue/NX-1234" rel="nofollow ugc">https://track.radensolutions.com/issue/NX-1234</a>. Should be an easy fix.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/22072</link><guid isPermaLink="true">https://forum.netxms.org/post/22072</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Sun, 02 Apr 2017 19:25:04 GMT</pubDate></item><item><title><![CDATA[Reply to Instance discovery method: script on Tue, 21 Mar 2017 15:16:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I found this out:</p>
<p dir="auto">In the template, the "Source Node" is set.<br />
Within the scripts, $node is set to the "Source Node", not to the node where the actual instance discovery happens (see screenshot).<br />
When trying the scripts using "Execute Server Script", $node is the "Discovery Node" and everything is fine.</p>
<p dir="auto">This is OK, I think, as most of the discovery will be done on the "Source Node" (and it's agent) anyway.</p>
<p dir="auto"><strong>Is there an easy way to get the "discovery" node into the scripts so I have access to the custom attributes of the discovery node ?</strong></p>
<p dir="auto">I want to create some checks on behalf node A and running on node B, controlled by node A's custom attributes.</p>
<p dir="auto">Thank you very much,</p>
<p dir="auto">Thomas</p>
<hr />
<p dir="auto"><img src="/assets/uploads/files/smf/0000000003500-netxms03.PNG" alt="netxms03.PNG" class="img-markdown  img-fluid" width="554" height="691" /></p>
]]></description><link>https://forum.netxms.org/post/22000</link><guid isPermaLink="true">https://forum.netxms.org/post/22000</guid><dc:creator><![CDATA[twenrich]]></dc:creator><pubDate>Tue, 21 Mar 2017 15:16:59 GMT</pubDate></item></channel></rss>