Ad Widget

Collapse

Actions and templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #1

    Actions and templates

    I have some problems with using swap and httpd in servers farm which finaly will be fixed on kernel level. I found temporary solution for my problems .. restart httpd.
    All my hosts are managed using template.
    I have defined trigger "[vol] [swap] < 50% free" in my Unix_t template.
    On all hosts in zabbix agent configuration is enabled remote command execution (EnableRemoteCommands=1) so I can run for example:

    $ zabbix_get -s <host> -k 'system.run["/usr/bin/sudo /etc/init.d/httpd restart"]'

    It reports "Timeout while executing operation." but it does't matter because above commant is executed correctly.

    OK .. lets start to define action:

    Configuration -> Actions ->

    Action type: Remote command
    Source: Trigger
    Conditions: "Trigger = "Unix_t: [vol] [swap] < 50% free""
    Remote command: "Unix_t:/usr/bin/sudo sudo /etc/init.d/httpd restart"

    and I don't see executing above on this trigger.

    Qustions:
    - what I'm doning wrong in above ?
    - how can I change/enlarge remote command execution timeout ?
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Originally posted by kloczek
    - what I'm doning wrong in above ?
    You're posting to a wrong forum obviously. Moved to ZABBIX Help.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • kloczek
      Senior Member
      • Jun 2006
      • 1771

      #3
      Originally posted by Alexei
      You're posting to a wrong forum obviously. Moved to ZABBIX Help.
      Sorry (my mistake).

      I'm modify condition in action to:

      Trigger = "Unix_t: [vol] [swap] < 50% free"
      Trigger value = "ON"

      and now waiting when this condition will be true.
      Now my general question is about Unix_t (template name) in remote command definition .. is it will be executed on correct host ?

      Next thing.
      Now in 1.3.x is possible to dump to XML file templates.
      Is it not will be better replace this by some geneneral configuration export/import ? (nevermind is it will in XML or SQL dump format (all tables without storred values).
      Probably implement this in SQL format will be much more easier (?).
      http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
      https://kloczek.wordpress.com/
      zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
      My zabbix templates https://github.com/kloczek/zabbix-templates

      Comment

      • kloczek
        Senior Member
        • Jun 2006
        • 1771

        #4
        Seems action with condition:

        Trigger = "Unix_t: [vol] [swap] < 50% free"
        Trigger value = "ON"

        and remote command:

        Unix_t:/usr/bin/sudo sudo /etc/init.d/httpd restart

        Again: bug o feacture ? (if second: what am I doing wrong ?)
        http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
        https://kloczek.wordpress.com/
        zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
        My zabbix templates https://github.com/kloczek/zabbix-templates

        Comment

        • Alexei
          Founder, CEO
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Sep 2004
          • 5654

          #5
          You may use macros in the latest 1.1.x. For example:

          "{HOSTNAME}:/usr/bin/sudo sudo /etc/init.d/httpd restart"

          So, the action will be executed for a proper host
          Alexei Vladishev
          Creator of Zabbix, Product manager
          New York | Tokyo | Riga
          My Twitter

          Comment

          • kloczek
            Senior Member
            • Jun 2006
            • 1771

            #6
            Originally posted by Alexei
            You may use macros in the latest 1.1.x. For example:

            "{HOSTNAME}:/usr/bin/sudo sudo /etc/init.d/httpd restart"

            So, the action will be executed for a proper host
            Does not work. On press "save" button I see error message:

            incorrect command: '{HOSTNAME}:/usr/bin/sudo /etc/init.d/httpd restart'

            In include/actions.inc:377 I see (I'm using 1.1.7):

            if(!ereg("^([0-9a-zA-Z\_\.-]{1,})(:|#)[[rint:]]*$",$cmd,$cmd_items)){
            error("incorrect command: '$cmd'");
            return FALSE;
            }

            and looks like {HOSTNAME} does not matches to first part of this regex.
            I'm jut fix command in action to remove double sudo word but it doesn't matter because I don't see logged any sudo execution using Unix_t in host name.
            Unix_t is inccorect and {HOSTNAME} can't be accepted by web frontend so looks like this part of code is buggy
            Last edited by kloczek; 15-05-2007, 13:32.
            http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
            https://kloczek.wordpress.com/
            zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
            My zabbix templates https://github.com/kloczek/zabbix-templates

            Comment

            • Alexei
              Founder, CEO
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Sep 2004
              • 5654

              #7
              You're right. The code is not in 1.1.x, yet it is supposed to work in 1.3.x.
              Alexei Vladishev
              Creator of Zabbix, Product manager
              New York | Tokyo | Riga
              My Twitter

              Comment

              • kloczek
                Senior Member
                • Jun 2006
                • 1771

                #8
                Originally posted by Alexei
                You're right. The code is not in 1.1.x, yet it is supposed to work in 1.3.x.
                Any chanses backport this fixes for this for 1.1.x ?
                http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
                https://kloczek.wordpress.com/
                zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
                My zabbix templates https://github.com/kloczek/zabbix-templates

                Comment

                • kloczek
                  Senior Member
                  • Jun 2006
                  • 1771

                  #9
                  Originally posted by Alexei
                  You're right. The code is not in 1.1.x, yet it is supposed to work in 1.3.x.
                  Seems it still doesn't work in 1.4.1.
                  http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
                  https://kloczek.wordpress.com/
                  zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
                  My zabbix templates https://github.com/kloczek/zabbix-templates

                  Comment

                  • Saftnase
                    Member
                    • Jul 2006
                    • 30

                    #10
                    can confirm this in 1.4.1
                    incorrect command: '{HOSTNAME}:shutdown -r'

                    and i would love to see this working in 1.4.2

                    Comment

                    • john
                      Junior Member
                      • Aug 2007
                      • 2

                      #11
                      As a workaround

                      As a -dirty- workaround in 1.4.1 (it works for us) :

                      In /include/actions.inc.php, inside function called 'validate_commands' :

                      1. Modify the line with ereg with this line :

                      Code:
                      if(!ereg("^([0-9a-zA-Z\_\.\{\}[.-.]]{1,})(:|#)[[:print:]]*$",$cmd,$cmd_items)){
                      2. Put comments for these lines :

                      Code:
                      // error("Unknown host name '".$cmd_items[1]."' incommand '".$cmd."'");
                      // return FALSE;

                      Comment

                      Working...