<?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[Assigning a Template based on installed software]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">While I can easily apply a template to a Windows system with a NetXMS Agent on it, I am having trouble narrowing this down further to, for example, systems running Microsoft Exchange, SQL or other software.<br />
NetXMS has the required data for this, but how do I test for this within the Template's Automatic Apply Rules?</p>
<p dir="auto">Of course I can apply a DCI to all Windows systems with a NetXMS Agent, run a test and use that, but I want to avoid having to add a DCI for this in the first place as the data already exists in NetXMS (why check twice?).</p>
<p dir="auto">Any ideas?</p>
]]></description><link>https://forum.netxms.org/topic/4102/assigning-a-template-based-on-installed-software</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:59:31 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4102.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Nov 2015 08:17:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Assigning a Template based on installed software on Tue, 17 Nov 2015 13:08:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">it requires changes in how Windows agent reads list of installed software. I'll try to fix that before 2.0 release.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/18330</link><guid isPermaLink="true">https://forum.netxms.org/post/18330</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 17 Nov 2015 13:08:30 GMT</pubDate></item><item><title><![CDATA[Reply to Assigning a Template based on installed software on Tue, 17 Nov 2015 12:14:48 GMT]]></title><description><![CDATA[<p dir="auto">Thanks! That worked without having to go through custom attributes. <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">I still had some issues with problem no. 1, as it "moved" from the DCI script to template auto-bind one.<br />
However adding another line of code resolved that. I also changed the script it to only apply to Windows systems.<br />
So now it looks like this and does not throw any more errors:</p>
<pre><code>if ( (! $node-&gt;isAgent) &amp;&amp; (! $node-&gt;platformName ~= "windows.*") )
	return false;

table = AgentReadTable($node, "System.InstalledProducts");

if ( table == null )
	return false;

colName = table-&gt;getColumnIndex("NAME");

for (currentRow = 0; currentRow &lt; table-&gt;rowCount; currentRow++)
{
	if ( table-&gt;get(currentRow, colName) == "Microsoft Exchange Server" )
		return true;
}

return false;
</code></pre>
<p dir="auto">Still not quite sure what to do in regards to installed Windows Features.  <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f615.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--confused" style="height:1.4em;width:auto;vertical-align:middle" title=":-\" alt="😕" /></p>
]]></description><link>https://forum.netxms.org/post/18329</link><guid isPermaLink="true">https://forum.netxms.org/post/18329</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Tue, 17 Nov 2015 12:14:48 GMT</pubDate></item><item><title><![CDATA[Reply to Assigning a Template based on installed software on Tue, 17 Nov 2015 10:43:27 GMT]]></title><description><![CDATA[<p dir="auto">I have modified the script for you so you can use it directly as a bind script.</p>
<p dir="auto">So use this as an auto-bind script on a template, and you dont need DCIs or custom attributes.<br />
It will also solve your issue no. 1.</p>
<pre><code>if (! $node-&gt;isAgent)
  return false;

table = AgentReadTable($node, "System.InstalledProducts");

colName = table-&gt;getColumnIndex("NAME");

for (currentRow = 0; currentRow &lt; table-&gt;rowCount; currentRow++)
{
  value = table-&gt;get(currentRow, colName);

  if (value == "Microsoft Exchange Server")
    return true;
}

return false;
</code></pre>
]]></description><link>https://forum.netxms.org/post/18328</link><guid isPermaLink="true">https://forum.netxms.org/post/18328</guid><dc:creator><![CDATA[tomaskir]]></dc:creator><pubDate>Tue, 17 Nov 2015 10:43:27 GMT</pubDate></item><item><title><![CDATA[Reply to Assigning a Template based on installed software on Tue, 17 Nov 2015 10:23:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">To answer my own question somewhat, I managed to do what I had planned by creating a script that checks System.InstalledProducts, returns "OK" (no matter what) and assigning this to a DCI.<br />
Along the way of checking that table, it sets custom attributes for any installed product that I want to monitor.<br />
That then allows me to apply templates to systems with those custom attributes set.</p>
<p dir="auto">Script below (for testing I only checked for Microsoft Exchange Server, but can be adjusted to other things):</p>
<pre><code>sub main()
{
	table=AgentReadTable($node,"System.InstalledProducts");
	idxName = table-&gt;getColumnIndex("NAME");
	for (row = 0; row &lt; table-&gt;rowCount; row++)
	{
 		value = table-&gt;get(row, idxName);
 		switch (value)
		{
 			case "Microsoft Exchange Server": SetCustomAttribute($node,"Microsoft Exchange Server","Installed");
		}
	}
	return "OK";
}
</code></pre>
<p dir="auto">Now I have a couple more problems:</p>
<ol>
<li>
<p dir="auto">My NetXMS server now keeps throwing up alarms against itself all the time: "Script (System::SetInstalledPackageAttributes) execution error: Error 14 in line 4: Function or operation argument is not an object". "System::SetInstalledPackageAttributes" being the name of the script. The script is not actually called against the server itself, so this appears to be an issue when the server calls it against a node? This DCI is only applied to systems with the NetXMS agent installed and running Windows. All of which should have System.InstalledPackages?</p>
</li>
<li>
<p dir="auto">This only works for software showing in that table, which doesn't include Remote Desktop Session Hosts or any other "Windows Feature". I could check for thos via (deprecated) WMI Query (which may also run into timeouts) or I would have to call PowerShell's Get-WindowsFeature cmdlet. Unfortunately I have currently no idea how to do that one in NetXMS... maybe an idea for a subagent? Together with uploading PowerShell scripts, that could be quite powerful?</p>
</li>
</ol>
]]></description><link>https://forum.netxms.org/post/18327</link><guid isPermaLink="true">https://forum.netxms.org/post/18327</guid><dc:creator><![CDATA[Tursiops]]></dc:creator><pubDate>Tue, 17 Nov 2015 10:23:57 GMT</pubDate></item></channel></rss>