External Parameter fail for agent daemon mode

Started by xatteg, August 12, 2016, 02:41:51 PM

Previous topic - Next topic

xatteg

Hi All,

I'm using external parameters in nxagentd.conf file, one of them:

ExternalParameter = CF2PRIVATEMEM:privatemem.sh

If I launch nxagentd -f -D 9  it executes and reads the parameter correctly

[12-Aug-2016 14:30:59.404] [DEBUG] [session:0] Received message CMD_GET_PARAMETER
[12-Aug-2016 14:30:59.404] [DEBUG] [session:0] Requesting parameter "CF2PRIVATEMEM"
[12-Aug-2016 14:30:59.404] [DEBUG] H_ExternalParameter called for "CF2PRIVATEMEM" "Eprivatemem.sh"
[12-Aug-2016 14:30:59.404] [DEBUG] RunExternal called for "CF2PRIVATEMEM" "Eprivatemem.sh"
[12-Aug-2016 14:30:59.404] [DEBUG] RunExternal: command line is "privatemem.sh"
[12-Aug-2016 14:30:59.405] [DEBUG] RunExternal (shell exec): worker thread created
[12-Aug-2016 14:30:59.502] [DEBUG] H_ExternalParameter/POpenWorker: worker thread pipe read result: 0x7f8e8f5a5d70
[12-Aug-2016 14:30:59.503] [DEBUG] RunExternal (shell exec): execution status 0
[12-Aug-2016 14:30:59.503] [DEBUG] [session:0] GetParameterValue(): result is 0 (SUCCESS)
[12-Aug-2016 14:30:59.503] [DEBUG] [session:0] Sending message CMD_REQUEST_COMPLETED (size 56)
[12-Aug-2016 14:30:59.503] [DEBUG] [session:0] Outgoing message dump:
  ** 001D0000000000380000001800000002
  ** 0000001C000000000000000000000000
  ** 00000015010000000000000C00340037
  ** 0037003300310032
  ** code=0x001D (CMD_REQUEST_COMPLETED) flags=0x0000 id=24 size=56 numFields=2
  ** [    28] INT32    0
  ** [    21] STRING   "477312"


However if I launch in daemon mode nxagentd -d -D 9  then I get the following

[12-Aug-2016 14:29:31.930] [DEBUG] [session:0] Received message CMD_GET_PARAMETER
[12-Aug-2016 14:29:31.930] [DEBUG] [session:0] Requesting parameter "CF2PRIVATEMEM"
[12-Aug-2016 14:29:31.930] [DEBUG] H_ExternalParameter called for "CF2PRIVATEMEM" "Eprivatemem.sh"
[12-Aug-2016 14:29:31.930] [DEBUG] RunExternal called for "CF2PRIVATEMEM" "Eprivatemem.sh"
[12-Aug-2016 14:29:31.930] [DEBUG] RunExternal: command line is "privatemem.sh"
[12-Aug-2016 14:29:31.930] [DEBUG] RunExternal (shell exec): worker thread created
[12-Aug-2016 14:29:31.936] [DEBUG] RunExternal (shell exec): execution status 0
[12-Aug-2016 14:29:31.936] [DEBUG] [session:0] GetParameterValue(): result is 0 (SUCCESS)
[12-Aug-2016 14:29:31.936] [DEBUG] [session:0] Sending message CMD_REQUEST_COMPLETED (size 48)
[12-Aug-2016 14:29:31.936] [DEBUG] [session:0] Outgoing message dump:
  ** 001D0000000000300000001900000002
  ** 0000001C000000000000000000000000
  ** 00000015010000000000000000000000
  ** code=0x001D (CMD_REQUEST_COMPLETED) flags=0x0000 id=25 size=48 numFields=2
  ** [    28] INT32    0
  ** [    21] STRING   ""

Which is wrong. Current version of server and agent is 2.0.5 and it does not work here.
When I had version 1.2.17 it worked correctly.

xatteg

I figured out that agent in daemon mode reacts with pain on sudo command in external script.
E.g. if script contain something

#!/bin/bash
echo 300

Than it works, but if we add sudo

sudo -u someuser echo 300

It does not. Did anyone run into this?

Alex Kirhenshtein

Try to remove "Defaults requiretty" from /etc/sudoers

xatteg