NetXMS Support Forum

English Support => General Support => Topic started by: Luis Montaño on July 06, 2017, 12:45:56 AM

Title: How to call a script from "instance-name" ?
Post by: Luis Montaño on July 06, 2017, 12:45:56 AM
Hello everyone, do you know how can I call a script from a dci description?
for example, this is the description of a dci: TrafficIN %{script:getIfNameByName({instance-name})}
this is my script:
scriptName:getIfNameByName
sub getIfName(netString)
{
     if (length(netString) > 0)
     array a;
     a [length(netString)];
     a = SplitString(netString, " ");
     return (a [
                       (a->size)-1
                  ]
              );
}
return getIfName($1);
how can I call that script and send "instance-name" as parameter?
Title: Re: How to call a script from "instance-name" ?
Post by: Tursiops on July 06, 2017, 01:01:38 AM
It looks to me as if what you are trying to do should probably be done in the instance discovery filter script, rather than via attempting to call a script within the DCI description?
Title: Re: How to call a script from "instance-name" ?
Post by: Luis Montaño on July 18, 2017, 11:30:23 PM
Yes your point is valid but I know that is possible, if I change the script and return any value, It appears on dci description.
I would like to know how to do it.
Title: Re: How to call a script from "instance-name" ?
Post by: Tursiops on July 19, 2017, 03:49:27 AM
Sounds like {instance-name} is not being interpreted prior to calling the script.
Maybe add some trace commands to your script, e.g. something like this:
trace(0,"Instance Name: ".$1);
Then check your server logs and see what is being returned: Nothing? Literally "{instance-name}"? Something else?
Title: Re: How to call a script from "instance-name" ?
Post by: Victor Kirhenshtein on July 25, 2017, 07:56:45 PM
Hi,

{instance-name} is a placeholder which is replaced only during instance discovery. You can set it's value by returning third element from instance filter script, like this:

return %(true, "this will became instance", "this will became instance name");

Best regards,
Victor