Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Problem with parameters for Agent Action (Linux-Server -> Win-Agent)

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

Scheduled Pinned Locked Moved Support
9 Posts 3 Posters 20.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    S
    Sack-C-Fix
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Z
      Z
      Tatjana Dubrovica
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • S
        S
        Sack-C-Fix
        wrote on last edited by
        #3

        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


        Edit action_Windows.jpg

        Edit action_Linux.jpg

        1 Reply Last reply
        0
        • S
          S
          Sack-C-Fix
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • F
            F
            Filipp Sudanov
            wrote on last edited by
            #5

            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"
            
            1 Reply Last reply
            0
            • S
              S
              Sack-C-Fix
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • F
                F
                Filipp Sudanov
                wrote on last edited by
                #7

                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?

                1 Reply Last reply
                0
                • S
                  S
                  Sack-C-Fix
                  wrote on last edited by
                  #8

                  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


                  action_linux.txt

                  action_win.txt

                  1 Reply Last reply
                  0
                  • S
                    S
                    Sack-C-Fix
                    wrote on last edited by
                    #9

                    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


                    Linux_Working_nxaction.txt

                    Windows_Working_nxaction.txt

                    Linux_NOT_Working_EPP.txt

                    Windows_NOT_Working_EPP.txt

                    1 Reply Last reply
                    0

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    Powered by NodeBB Contributors
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups