Source node and templates?

Started by pvo, March 24, 2020, 11:18:47 AM

Previous topic - Next topic

pvo

I have some SSH DCIs which run the ssh commands on different server using Source node setting.
It works fine when I configure the DCI directly on a Node but different Nodes needs to use different Source nodes therefore I have problem to convert these commands to templates.

When I set  the Source node in the template the same Source node is copied to all Nodes a when I leave it empty it is empty on all Nodes.

I've tried to set the SSH Proxy on the Node, but it is not used by the SSH DCIs. I probably din 't understood the SSH Proxy functionality and I didn't find any description in the Administrator Guide.

What is the reason for SSH Proxy and how it works?

Is it possible to configure what I need (= different Source nodes for DCIs assigned from a template)?

Thank you in advance for any help.



Victor Kirhenshtein

SSH proxy setting determines which node will establish actual SSH connection. If you are using source node then server will read SSH settings on that node, not on a node where DCI is configured (because connection goes to source node, not DCI owning node).

Currently there is no way to set different source nodes from template. What you can do it to use script DCI instead of SSH DCI, and in script code identify correct source node and call executeSSHCommand on it.

Best regards,
Victor

pvo

#2
There is a problem with this solution.

The executeSSHCommand doesn't return any values. It even doesn't return any error if the command was not found.

pvo

I've checked the source code for the executeSSHCommand function and if I understand it right the output of the ssh command is converted to a string array and stored in the memory specified by the C result variable.
Unfortunately I don't know how to access these data form a nxsl script.

I've seen that lot of other nxsl functions return void as well as the the executeSSHCommand function does. Therefore I guess there is some posibility to access these data, but I didn't found any example.

Without output form the ssh command the executeSSHCommand doesn't help me to to implement the script DCI calling ssh command.

Can anybody help me?

pvo

I'm a stupid newbie. I've tested the output from  executeSSHCommand with println and it cannot write an array.

This works fine:
ret = $node->executeSSHCommand("/opt/test/test.sh");

println ArrayToString(ret, "\n");  // prints all lines
println ret[0];  // prints first line only