NetXMS Support Forum

Development => General => Topic started by: pouya.moradian on October 11, 2015, 04:42:02 PM

Title: Action
Post by: pouya.moradian on October 11, 2015, 04:42:02 PM
Hi,

Is there any way to get data from action ?
Is there any way to pass argument to action functions?
There is a Boolean return value for each action function in java sub agent, what is it for?
And also there is some parameter (String action, String[] args) what is it for?

with best regards
Pouya
Title: Re: Action
Post by: Victor Kirhenshtein on October 16, 2015, 06:32:57 PM
Hi,

no you cannot get data from action. You can pass arguments to action - in server configuration you specify them separated by spaces (like in normal command line). When action is called, String[] args will contain those arguments. Boolean return value is to indicate if action was executed successfully.

Best regards,
Victor
Title: Re: Action
Post by: pouya.moradian on October 17, 2015, 08:50:47 AM
Hi,

Thanks for your reply,

I defined action in object tool, is it right? because i saw an action configuration in configuration menu strip.
Also i used {DeviceActionName arg1 arg2} in agent's command field in object tool but on execute i got : Cannot execute action on node {NodeName}: Communication failure

With Best Regards
Pouya
Title: Re: Action
Post by: Victor Kirhenshtein on October 17, 2015, 07:42:11 PM
Hi,

did you define action correctly in subagent? Can you show code registering your action?

Best regards,
Victor
Title: Re: Action
Post by: pouya.moradian on October 19, 2015, 02:00:22 PM
Hi,

Here is my action code in some class that extends the Plugin, the other part of code are same as the sample code in  ..\netxms-snapshot-develop\src\agent\subagents\java\sample\
All of my parameters and  actions work fine in this class but passing parameter to actions is not possible and the action.txt file only contain "Action has been executed" !

Thanks
Title: Re: Action
Post by: Victor Kirhenshtein on October 24, 2015, 07:17:11 PM
Code seems to be correct. Try to check with nxget that action was registered:

nxget -l agent_ip_addr Agent.ActionList

Also, make sure you are using correct action name in object tool. You can also execute agent action from command line using nxaction command.

Best regards,
Victor
Title: Re: Action
Post by: pouya.moradian on October 25, 2015, 07:51:27 AM
The Action is already registered (as it name appear in node's supported action list),
but there is no nxaction binary fine in ..\NetXMS\bin in client side !
I'm using 2.0 RC 1 agent.

With best regards,
Pouya
Title: Re: Action
Post by: Victor Kirhenshtein on October 25, 2015, 07:51:06 PM
Hi,

nxaction is a server side tool.

Best regards,
Victor
Title: Re: Action
Post by: pouya.moradian on November 01, 2015, 08:15:17 AM
Hi

You're right that's server side, And i can see my action is registered here !


[root@netxmslinux bin]# nxget -l 192.168.11.84 Agent.ActionList
Agent.Restart 2 "CORE"
System.Restart 2 "WinNT"
System.Shutdown 2 "WinNT"
DeviceLogAction 2 "JAVA"

Each time i use nxaction some error occur : Required argument(s) missing.
Can i have some example for using nxaction ?

My command is :
nxaction DeviceLogAction -a 'none' -e 0 -K /usr/local/var/lib/netxms/.server_key -p 4700 -w 5 -W 30

I Also tried to check each one of these option by removing them,
and it does not work.

Thanks for your reply,
Pouya
Title: Re: Action
Post by: Victor Kirhenshtein on November 06, 2015, 12:47:33 PM
You have to specify agent address in command line as well (before action name).

Best regards,
Victor
Title: Re: Action
Post by: pouya.moradian on November 28, 2015, 08:56:54 AM
Hi

Thanks a lot, it works fine.
the full format of action execution command is like:

nxaction NodeIP ActionName ParameterHere  -a 'none' -e 0 -K /usr/local/var//lib/netxms/.server_key -p 4700 -w 10 -W 30

it may help someone else.