Ad Widget

Collapse

Running External Commands or Commands through Actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abel5405
    Member
    • Jan 2019
    • 47

    #1

    Running External Commands or Commands through Actions

    Greetings All,
    I created an item that measures the amount of disk space uncompressed IIS logs take up on a particular drive. When the size exceeds a specified limit I need it to run a command script to compress the logs. I have created the trigger and the action for the trigger to call the cab script local on the target Windows box. The Item and Trigger work fine but when it try's to run the action it get's the following error:

    "Get value from agent failed: ZBX_TCP_READ() timed out"

    No matter how I configure the action or trigger I get the same error. What am I doing wrong? Many thanks as always for any help.

    v/r
    Chris
  • ingus.vilnis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2014
    • 908

    #2
    Hi Chris,

    Can Zabbix Server connect to the remote agent in the first place?

    telnet <remote agent IP> 10050

    If telnet gets through, it may be that the script execution takes long time, longer than the default 3 seconds set in zabbix_agentd.conf file. Increase Timeout=30, restart the agent to apply and see again. However, if the script takes even longer then probably put a caller script which returns answer to Zabbix immediately and executes the other script not waiting for it to end.

    Comment

    • abel5405
      Member
      • Jan 2019
      • 47

      #3
      Originally posted by ingus.vilnis
      Hi Chris,

      Can Zabbix Server connect to the remote agent in the first place?

      telnet <remote agent IP> 10050

      If telnet gets through, it may be that the script execution takes long time, longer than the default 3 seconds set in zabbix_agentd.conf file. Increase Timeout=30, restart the agent to apply and see again. However, if the script takes even longer then probably put a caller script which returns answer to Zabbix immediately and executes the other script not waiting for it to end.
      Thanks Vilnis for the quick reply! The Zabbix timeout is set to 30 seconds for the agent and the proxy server can hit the agent on 10050. How would I setup a caller script that you mention, can not seem to find it in the docs. Again many thanks for the reply!

      v/r
      Chris

      Comment

      • ingus.vilnis
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Mar 2014
        • 908

        #4
        Remote commands must be enabled in both Proxy and Agent config files (disabled by default).


        And what version of Zabbix do you run there? Remote commands via proxies are supported only starting from Zabbix 3.4.0.

        How long does the compression take before we get to any additional scripting?

        Comment

        • abel5405
          Member
          • Jan 2019
          • 47

          #5
          Originally posted by ingus.vilnis
          Remote commands must be enabled in both Proxy and Agent config files (disabled by default).
          https://www.zabbix.com/documentation...remote_command

          And what version of Zabbix do you run there? Remote commands via proxies are supported only starting from Zabbix 3.4.0.

          How long does the compression take before we get to any additional scripting?
          We are on Zabbix 3.4.15. The compression script could take up to 15 minutes to run completely through depending on how many log files there are to compress.

          Edit: I did go through the remote command section of the PDF but still get the same error.

          Comment

          • ingus.vilnis
            Senior Member
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Mar 2014
            • 908

            #6
            Can you check whether the compression is actually run and finished successfully even if Zabbix returns you timeout error? I wonder what happens if the script is executed. I would not expect Zabbix agent to kill it immediately after timeout.

            Comment

            • abel5405
              Member
              • Jan 2019
              • 47

              #7
              Originally posted by ingus.vilnis
              Can you check whether the compression is actually run and finished successfully even if Zabbix returns you timeout error? I wonder what happens if the script is executed. I would not expect Zabbix agent to kill it immediately after timeout.
              We are able to run the script manually with no issue.

              Comment

              • ingus.vilnis
                Senior Member
                Zabbix Certified Trainer
                Zabbix Certified SpecialistZabbix Certified Professional
                • Mar 2014
                • 908

                #8
                Yes, that is clear. But I wonder what happens when Zabbix action throws this error. Is the script still executed on the target host (even if Zabbix could not wait till it finishes because of timeout)?

                Comment

                • abel5405
                  Member
                  • Jan 2019
                  • 47

                  #9
                  My apologize for misunderstanding, The script doe not run on the target. I see it go to "In Progress" for about 30 seconds then fail.

                  Comment


                  • morphlingg
                    morphlingg commented
                    Editing a comment
                    maybe it had failed immediatly and after 30 seconds only gave the message
                Working...