[SOLVED] ActionShellExec Confusion...

Started by lweidig, February 18, 2022, 08:23:38 PM

Previous topic - Next topic

lweidig

I am trying to do a simple update of node status into a MS-SQL server when the status on a node changes.  I have written a really simply .cmd file to handle passing in the hostname, ip address, status and comment.  Can run this from the command prompt on the server and it works as expected.

On the server running the agent we have the following:


ActionShellExec = Sql.StatusUpdate:D:\nodeUpdate.cmd $1 $2 $3 $4


If I enable debugging on the agent can see this is getting fired off:

2022.02.18 13:06:23.802 *D* [comm.cs.232        ] Received message CMD_ACTION (4)
2022.02.18 13:06:23.811 *D* [procexec           ] ProcessExecutor::execute(): process "CMD.EXE /C D:\nodeUpdate.cmd host.com 1.2.3.4 down Yikes" started
2022.02.18 13:06:23.812 *D* [actions            ] Execution of external action Sql.StatusUpdate (D:\nodeUpdate.cmd host.com 1.2.3.4 down Yikes) started
2022.02.18 13:06:23.812 *D* [actions            ] ExecuteAction(Sql.StatusUpdate): requestId=4, RCC=0
2022.02.18 13:06:23.812 *D* [comm.cs.232        ] Sending message CMD_REQUEST_COMPLETED (ID 4; size 32; uncompressed)


One of the first thing the script does is echo the parameters to a temporary file, so we have some history.  That is never getting triggered and definitely the sqlcmd statement in the script is not running.  Have been pulling my hair out for a while and cannot figure out why this is not working.

Ideally, though at this point becoming less of a bid deal that last parameter should allow for a string with spaces.  That at this point is icing on the cake, just want it working.

Thoughts?

lweidig

Following up on my own post, but still hoping for some clarity.  This fails running AgentExecuteAction on the node, but works if I run nxaction from the server command line.  The exact calls are as follows:

Does not work:

AgentExecuteAction($node, "Sql.StatusUpdate","host.com","1.2.3.4","down","YIKES");





Works:

nxaction -s NOTTREALKEYHERE -o sql.host.com "Sql.StatusUpdate" "host.com" "1.2.3.4" "down" "YIKES"

Maybe AgentExecuteAction does not handle shared secrets properly? 

Victor Kirhenshtein

Hi,

what server version you are using? Also, try to set debug level to 5 on server and check server log for lines starting with NXSL: F_AgentExecuteAction.

Best regards,
Victor

lweidig

The previous posts were all running in 3.9.xxx (I believe 420).  We have upgraded now to 4.0.2157 and we are not having issues any longer with this.