Problem with parameters for Agent Action (Linux-Server -> Win-Agent)

Started by Sack-C-Fix, December 04, 2019, 02:26:02 PM

Previous topic - Next topic

Sack-C-Fix

Hi everyone,

I have a problem with executing an agent´s action via EPP and found also some strange behaviour on Linux, systems are:

  • Server-Linux: Debian 9, NetXMS-Server 3.0.2357
  • Server-Windows: Server 2012 R2, NetXMS-Server 2.2.16
  • Agent-Windows: Server 2012 R2, NetXMS-Agent 3.0.2357

What i want is to execute a cmd-Script (send message) on the Windows-Agent, tested it with following config (nxagentd.conf)

...
EnableActions = yes
Action = notify: C:\\Local\\Binw\\Notify_V3.cmd -S $1 -D $2 -M $3 -G $4 -L $5
...


Using parameters for the action, things get strange on the Linux-Server:
/bin/# ./nxaction -o 192.168.9.40 notify Test2 NetXMS E NetXMS2 LinNXACTION

Working, i get mail:
Executing action C:\\Local\\Binw\\Notify_V3.cmd -S Test -D NetXMS -M E -G NetXMS2 -L LinNXACTION of type 1

Via Action + EPP, not working:
Executing action C:\\Local\\Binw\\Notify_V3.cmd -S Test NetXMS E NetXMS2 LinEPP -D NetXMS E NetXMS2 LinEPP -M E NetXMS2 LinEPP -G NetXMS2 LinEPP -L LinEPP of type 1

I tried almost 50 different versions of the config (using " or ' around single parameters, all parameters, escaping the parameters with \" an \' and so on), but i always get a result like the above.
Seems there is an problem transmitting and escaping the string from Linux to Windows, because if i use same config from within Windows-Server i get (which is also not working):
Executing action C:\\Local\\Binw\\Notify_V3.cmd -S Test -D NetXMS -M E -G NetXMS2 -L WinEPP of type 1

So, is this a known problem or am i doing it wrong?
And, has someone a working example of using an action with multiple parameters?

Thanks

Andreas

Tatjana Dubrovica

Can you also provide how does action call is configured on server side: I mean server action (Configuration->Action Configuration), that calls agent action?

Sack-C-Fix

Hello,

Configs are in the files attached, I there also tried to escape ("", '', \", \') the parameters.
Results stay the same, on Windows i get the correct parameter per string, on Linux the parameters are passed multiple times.

Thanks

Sack-C-Fix

Hmm,
maybe related to the problem (or i'm too stupid to use parameters correctly).

If i execute a internal script via GUI's Server Console and pass multiple parameters, strings are split at blanks, even if enquoted by "".

Example: exec myScript 123 456 "Hello World"
So for this i get $1 = 123, $2 = 456, $3 = "Hello, $4 = World", i was expecting to get the complete string for $3.

Any thoughts on this?

Andreas

Filipp Sudanov

As for the first problem with executing an agent´s action via EPP, it was fixed and should work in version 3.1.261 that was released yesterday. Could you please confirm that it works for you?

There is currently no way to pass script arguments that have spaces from GUI's Server Console (and also from nxadm -c). Possible workarounds:
- use some special character, e.g. _ and replace it in the script
- you can use nxscript command line utility, but it can not run scripts from server script library, the script should be in a file.
nxscript 1.nxs "1" "2 3"

Sack-C-Fix

Hello,

forgot to reply to your answer.
With the new version at least the entry in the log-file seems correct, but executing the action is still not working.

Has someone a working example of executing a script via nxagent?

Thanks
Andreas

Filipp Sudanov

Hi!

Can we get some more details on how exactly it's not working? Can you may be try to call a command file, that logs parameters that it's receiving and show what is in netxms agent's log and what that command file gets?

Sack-C-Fix

Okay,

tried a few things and found following behaviour.
As mentioned above, executing action from CLI/CMD via nxaction on Agent (Windows) works from server (Windows and Linux).

Executing the action via EPP only works on Windows-Server, seems Linux-Server can't find the correct action.
Log-Files are attached, the first lines show command executed on server, followed by reaction on agent.

Thanks
Andreas

Sack-C-Fix

Hmm,

still no progress despite further investigations.

Executing the external action, this time without additional parameters, via nxaction works on Linux and Windows.
Action executed via EPP does not work on Linux and Windows, there are missing around 220 lines in the log of the agent.

So, is this a bug or am i calling the action wrong as stated above?

Andreas