<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Agent Actions parameters not working]]></title><description><![CDATA[<p dir="auto">I am trying to call an action from an agent with a parameter. I defined the action in the agent's config file like this:</p>
<pre><code>ActionShellExec = Echo: /tmp/script.sh $1
</code></pre>
<p dir="auto">The script only echo's it's first parameter to a file.</p>
<p dir="auto">I am trying to call the action from an Action Object Tool.<br />
If I define "Agent's Action" as: Echo, it works and I get in agent's log file with debug level 9 the following:</p>
<pre><code>[02-Sep-2014 09:48:19.708] [DEBUG] [session:1] Message dump:
  ** 00430000000000380000000200000002
  ** 00000057010000000000000800450063
  ** 0068006F6E205B3200000058007FF229
  ** 0000000000000000
  ** code=0x0043 (CMD_ACTION) flags=0x0000 id=2 size=56 numFields=2
  ** [    87] STRING "Echo"
  ** [    88] INT32  0

[02-Sep-2014 09:48:19.708] [DEBUG] [session:1] Received message CMD_ACTION
[02-Sep-2014 09:48:19.708] [DEBUG] Executing action Echo of type 3
[02-Sep-2014 09:48:19.708] [DEBUG] SH_EXEC: Expanding command "/tmp/script.sh"
[02-Sep-2014 09:48:19.708] [DEBUG] SH_EXEC: Executing "/tmp/script.sh"
[02-Sep-2014 09:48:19.714] [DEBUG] [session:1] Sending message CMD_REQUEST_COMPLETED (size 32)
[02-Sep-2014 09:48:19.715] [DEBUG] [session:1] Session with 10.20.1.7 closed
</code></pre>
<p dir="auto">But if I define "Agent's Action" as: Echo parameter1, it fails with a communication failure.<br />
The log looks like this:</p>
<pre><code>[02-Sep-2014 09:51:59.670] [DEBUG] [session:1] Message dump:
  ** 00430000000000500000000200000002
  ** 00000057010000000000001E00450063
  ** 0068006F00200070006100720061006D
  ** 0065007400650072003100004C000000
  ** 00000058007F00000000000041006700
  ** code=0x0043 (CMD_ACTION) flags=0x0000 id=2 size=80 numFields=2
  ** [    87] STRING "Echo parameter1"
  ** [    88] INT32  0

[02-Sep-2014 09:51:59.670] [DEBUG] [session:1] Received message CMD_ACTION
[02-Sep-2014 09:51:59.670] [DEBUG] [session:1] Sending message CMD_REQUEST_COMPLETED (size 32)
[02-Sep-2014 09:51:59.671] [DEBUG] [session:1] Session with 10.20.1.7 closed
</code></pre>
<p dir="auto">This happens in version 1.2.14 and 1.2.16 also.</p>
<p dir="auto">Thank you,<br />
Vlad</p>
]]></description><link>https://forum.netxms.org/topic/3347/agent-actions-parameters-not-working</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:59:28 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/3347.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 02 Sep 2014 10:06:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Agent Actions parameters not working on Sun, 21 Sep 2014 17:22:25 GMT]]></title><description><![CDATA[<pre><code>--- "a/C:\\Users\\VS2005\\AppData\\Local\\Temp\\TortoiseGit\\ses76AB.tmp\\session-b45e65c-left.cpp"
+++ "b/C:\\Code\\netxms-v1.2.16\\src\\server\\core\\session.cpp"
@@ -7269,7 +7269,15 @@ void ClientSession::executeAction(CSCPMessage *pRequest)
             if (pConn != NULL)
             {
                pRequest-&gt;GetVariableStr(VID_ACTION_NAME, szAction, MAX_PARAM_NAME);
-               dwResult = pConn-&gt;execAction(szAction, 0, NULL);
+			   int argc = pRequest-&gt;getFieldAsInt32(VID_NUM_ARGS);
+			   TCHAR **argv = new TCHAR*[argc];
+			   for (int i = 0; i &lt; argc; i++)
+			   {
+				   argv[i] = new TCHAR[256];
+				   pRequest-&gt;GetVariableStr(VID_ACTION_ARG_BASE + i, argv[i], 256);
+			   }
+               dwResult = pConn-&gt;execAction(szAction, argc, argv);
+			   free(argv);

                switch(dwResult)
                {
</code></pre>
<pre><code>--- "a/C:\\Users\\VS2005\\AppData\\Local\\Temp\\TortoiseGit\\NXC2518.tmp\\NXCSession-b45e65c-left.java"
+++ "b/C:\\Code\\netxms-v1.2.16\\src\\java\\netxms-client\\src\\main\\java\\org\\netxms\\client\\NXCSession.java"
@@ -4408,14 +4408,21 @@ public NetworkMapPage queryLayer2Topology(final long nodeId) throws IOException,
     *
     * @param nodeId Node object ID
     * @param action Action name
+    * @param args Action arguments
     * @throws IOException  if socket I/O error occurs
     * @throws NXCException if NetXMS server returns an error or operation was timed out
     */
-   public void executeAction(final long nodeId, final String action) throws IOException, NXCException
+   public void executeAction(final long nodeId, final String action, String[] args) throws IOException, NXCException
    {
       NXCPMessage msg = newMessage(NXCPCodes.CMD_EXECUTE_ACTION);
       msg.setVariableInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
       msg.setVariable(NXCPCodes.VID_ACTION_NAME, action);
+      if (args != null)
+      {
+	      msg.setVariableInt32(NXCPCodes.VID_NUM_ARGS, args.length);
+	      for (int i=0; i&lt;args.length; i++)
+	    	  msg.setVariable(NXCPCodes.VID_ACTION_ARG_BASE + i, args[i]);
+      }
       sendMessage(msg);
       waitForRCC(msg.getMessageId());
    }
</code></pre>
<pre><code>--- "a/C:\\Users\\VS2005\\AppData\\Local\\Temp\\TortoiseGit\\Obj1C3B.tmp\\ObjectToolExecutor-b45e65c-left.java"
+++ "b/C:\\Code\\netxms-v1.2.16\\src\\java\\netxms-eclipse\\ObjectTools\\src\\org\\netxms\\ui\\eclipse\\objecttools\\api\\ObjectToolExecutor.java"
@@ -173,8 +173,30 @@ private static void executeTableTool(final NodeInfo node, final ObjectTool tool)
     */
    private static void executeAgentAction(final NodeInfo node, final ObjectTool tool)
    {
-      final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
-      final String action = substituteMacros(tool.getData(), node);
+	  final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+	  String _action = substituteMacros(tool.getData(), node);
+
+	  if (_action.endsWith("(*)"))
+	  {
+			InputDialog dlg = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+					Messages.get().ObjectToolsDynamicMenu_Information, "Parameter", "", null); //$NON-NLS-1$
+			if (dlg.open() != Window.OK)
+				return;
+
+			_action = _action.replace("(*)", "(" + dlg.getValue() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	  }
+
+      String[] _args = null;
+      if (_action.indexOf('(') &gt; 0)
+      {
+    	  String a = _action.substring(_action.indexOf('(') + 1, _action.length() - 1);
+    	  _args = a.split(",");
+    	  for (int i = 0; i &lt; _args.length; i++) _args[i] = _args[i].trim();
+    	  _action = _action.substring(0, _action.indexOf('(') + 1) + "*)";
+      }
+      final String action = _action;
+      final String[] args = _args;
+
       new ConsoleJob(String.format(Messages.get().ObjectToolsDynamicMenu_ExecuteOnNode, node.object.getObjectName()), null, Activator.PLUGIN_ID, null) {
          @Override
          protected String getErrorMessage()
@@ -185,7 +207,7 @@ protected String getErrorMessage()
          @Override
          protected void runInternal(IProgressMonitor monitor) throws Exception
          {
-            session.executeAction(node.object.getObjectId(), action);
+            session.executeAction(node.object.getObjectId(), action, args);
             runInUIThread(new Runnable() {
                @Override
                public void run()
</code></pre>
]]></description><link>https://forum.netxms.org/post/14920</link><guid isPermaLink="true">https://forum.netxms.org/post/14920</guid><dc:creator><![CDATA[flytech-ben]]></dc:creator><pubDate>Sun, 21 Sep 2014 17:22:25 GMT</pubDate></item><item><title><![CDATA[Reply to Agent Actions parameters not working on Sun, 21 Sep 2014 15:33:06 GMT]]></title><description><![CDATA[<p dir="auto">I've fixed this. After I fixed it I found out that the server doesn't pass the parameters to the agent, so I had to fix this to.<br />
And while I were at it I also added a dialog for passing parameters when invoking the action when (*) is used in action name  <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
<p dir="auto">Victor, can I provide you the code in any way or do want to fix it yourself?</p>
<p dir="auto">Best whishes,<br />
Ben</p>
]]></description><link>https://forum.netxms.org/post/14919</link><guid isPermaLink="true">https://forum.netxms.org/post/14919</guid><dc:creator><![CDATA[flytech-ben]]></dc:creator><pubDate>Sun, 21 Sep 2014 15:33:06 GMT</pubDate></item><item><title><![CDATA[Reply to Agent Actions parameters not working on Tue, 02 Sep 2014 19:44:02 GMT]]></title><description><![CDATA[<p dir="auto">Yes, actually actions in object tools does not support parameters. Entire string interpreted as action name. I'll register this as a bug.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/14826</link><guid isPermaLink="true">https://forum.netxms.org/post/14826</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 02 Sep 2014 19:44:02 GMT</pubDate></item></channel></rss>