NetXMS Support Forum

English Support => General Support => Topic started by: Borgso on December 11, 2013, 02:38:11 PM

Title: AutoAdd node if last value is X
Post by: Borgso on December 11, 2013, 02:38:11 PM
Is it possible to autoadd a node if i have a Generic template gathering a value i want to decide where the node should be put?

Ex i have template that check for program version "Templates->Generic->AppVersion"

If AppVersion >=1.0 add to node to "Templates->Generiv_v1"
If AppVersion >=2.0 add to node to "Templates->Generiv_v2"
Title: Re: AutoAdd node if last value is X
Post by: KjellO on December 11, 2013, 10:27:52 PM
It is possible to check DCI values in template autoapply scripts.

In the generic template, create a DCI that collects the application version.
In the autoapply script of the version-specific template use something like this. (Not tested, may contain errors)

sub main() {
   ver = GetDCIValue($node, FindDCIByName($node, "AppVersion(theApp)"));
   // nxsl finally uses short-circuit evaluation :-)
   return (ver != NULL && $node->name ~= "node-name-regexp" && real(ver) > 1.2 && real(ver) < 2.0);
}


Title: Re: AutoAdd node if last value is X
Post by: Borgso on December 12, 2013, 04:38:19 PM
Thanks for the help.

I ended up with this AutomaticApplyRules that worked:

sub main() {
   $ver = GetDCIValue($node, FindDCIByDescription($node, "AppVersionDescription"));
   return ($ver != NULL &&
           $node->name ~= "node-name-regexp" &&
           real($ver) > 2);
}