NetXMS Support Forum

English Support => General Support => Topic started by: aron on January 24, 2014, 05:51:25 PM

Title: Using a template with ExternalParameterShellExec
Post by: aron on January 24, 2014, 05:51:25 PM
Hello

We have a very interesting automation/management challenge. We have a requirement to pull out a value from a LDAP server. We have currently implemented as below;

ExternalParameterShellExec=LdapQuery(*):/home/access/ldap.sh $1 $2 $3 $4

which in turn executes;

ldapsearch -P 2 -D Username -h $1 -w $2 -s sub "(objectclass=XXX)" -b "GUID=$3" -LL $4 | grep "$4" | sed "s/$4: //"

However it is deploying the DCI's to the nodes which I can not think of an effective way of doing. We would like a way of managing the TemplatedDCI and Thresholds globally but with local variables configured in the Node. The nodes are currently deployed in a template group which applies other DCI's. All the Nodes that the template is assigned against are networking equipment which can not run nxagentd. The volume of Nodes/DCI's that are needed to be created and maintained would make would make it infeasible to try and do manually.

The two approaches that I can think of doing this would be with a DCI like;
LdapQuery(GetCustomAttribute("ip"),GetCustomAttribute("user"),GetCustomAttribute("GUID"),GetCustomAttribute("value")) and having this run on the unit with the LdapQuery configuration set.

But this understandably it did not expect a nested function to be called.

Or alternatively run it as internal/Dummy and in the script get the CustomAttribute. However I am not sure of a way to call the LdapQuery function remotely.

Wondered if anyone else was aware of a different approach?

Regards

Aron
Title: Re: Using a template with ExternalParameterShellExec
Post by: Victor Kirhenshtein on January 25, 2014, 02:16:02 PM
Hi!

I see few possible solutions here.

1. Use dummy DCI, and in transformation script call AgentReadParameter (http://wiki.netxms.org/wiki/NXSL:AgentReadParameter) to get LdapQuery from agent with required parameters.

2. If values of custom attributes not changing, you can embed them into DCI on template apply time using template macros (https://www.netxms.org/documentation/adminguide/data-collection.html#macros-in-template-items). It could be something like


LdapQuery(%{script:LdapParameters})


and in script library you can create script named LdapParameters like this:


return GetCustomAttribute($node, "ip") . "," . GetCustomAttribute($node, "user") . "," . GetCustomAttribute($node, "GUID") . "," . GetCustomAttribute($node, "value");


Best regards,
Victor
Title: Re: Using a template with ExternalParameterShellExec
Post by: aron on January 27, 2014, 12:46:16 PM
Hello

Thank you, have applied successfully with the AgentReadParameter. :)

Regards

Aron