Ad Widget

Collapse

How does Zabbix execute actions ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tehcook
    Junior Member
    • Apr 2015
    • 2

    #1

    How does Zabbix execute actions ?

    Sorry if this is an obvious question, just could not find anything in the docs or figure out from the interface looks.

    I'm looking at Configuration-Actions-Auto Registration. Does Zabbix execute each Action in the order of the list ? That would be my first guess except there is no way to reorder rules. Most other tools that execute items one by one allow move one in front of the others.

    I dont think Zabbix does anything like "most specific" match.

    And its unlikely to do "first match" because it obviously can execute few actions from the list.

    So how does Zabbix execute actions ? Whats the order ? Say first action does something and then later another action overwrites it. Will the result be what the last applicable action did ?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    The processing of actions is not ordered by any means.
    Zabbix queries all active actions of the corresponding type on each event (e.g. auto-registration) unsorted. Then it checks each action whether all of its conditions are met and does escalation/operation where necessary.

    See actions.c

    Comment

    • tehcook
      Junior Member
      • Apr 2015
      • 2

      #3
      Thanks for clarification. So if there are two actions that match same event but do opposite things - then its uncertain what will be the result.

      I think Zabbix would absolutely benefit from enforcing actions execution order and have a way to reorder list of actions. Say you need to sort hosts across different groups and by default place hosts in group A. It's much easier to first setup default action to place any host into group A. And then more specific actions that may reassign host to a different group based on some criteria.

      Comment

      • BDiE8VNy
        Senior Member
        • Apr 2010
        • 680

        #4
        Feel free to create a proper feature request on https://support.zabbix.com/.

        Comment

        • cdslaughter
          Member
          • Jun 2018
          • 69

          #5
          This is a good question. Is there still no clear answer on this?
          I would have thought it might have done them in order of the lowest action ID to the largest action id (The database ID for each action)

          There has to be some sort of logic, Just wonder if anyone has the ability to read the code and decipher it for the rest of us.

          Carl

          Comment

          • kloczek
            Senior Member
            • Jun 2006
            • 1771

            #6
            Agent sends query for cfg.
            If there is no on the server.proxy cfg for the host it is forwarded if req has been received by the proxy to the server.
            Server tests autoregistration actions against criteria defined in actions conditions.
            If One of the action gives positive result agaunst condition host is registered using set of steps defined in action.
            On next update updated cfg is pushed to the proxy.
            Proxy or server on next agent reply is able to return exact set monitoring cfg .
            Agent starts monitoring and pushing monitoring data to server/proxy.

            That is all. There are few other minor steps but above contains +95% of what is done during autoregistration.
            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

            • cdslaughter
              Member
              • Jun 2018
              • 69

              #7
              Perhaps I should be moer specific.
              Lets say I have 3 auto registration ruled.
              I) no parameters, but an operation of add host.
              2) meta data like "foo", and an operation of add template name "Foo"
              3) metadata like "earth", and operation of run script fly_me_toTheMoon.sh "{HOST.NAME}"

              My meta data on a host that just had the agent installed.
              foolish, earthlings,love,mars

              Which of these actions would be run and in what order would they be run.

              Carl

              Comment

              • kloczek
                Senior Member
                • Jun 2006
                • 1771

                #8
                If you will add the host it will be without any metrics. Just registered host.
                Part of the autoregistration action should be add use template or templates.
                If you want to use what returns agent metadata (HostMetadataItem or HostMetadata in agent configuration) that is your choice.
                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

                • cdslaughter
                  Member
                  • Jun 2018
                  • 69

                  #9
                  Ok, I ran a test and although the test was simplistic, so far it looks like it finds all the actions that have matching criteria and then runs them in order based on the actions "actionId"

                  the output below is from a script that I wrote to test auto registration order.. The first column is unix time, second column is the actionId number and the 3rd is the hostname
                  Timestamp ActionId Hostname
                  1538419320 19 202719ZBXWIN01
                  1538419320 21 202719ZBXWIN01
                  1538419320 23 202719ZBXWIN01
                  1538419557 19 202719ZBXWIN01
                  1538419557 21 202719ZBXWIN01
                  1538419557 23 202719ZBXWIN01
                  1538419562 23 202719carl-lpgate013
                  1538419682 23 202719carl-lpgate013
                  1538419802 23 202719carl-lpgate013
                  1538419925 23 202719carl-lpgate013
                  1538420045 19 202719carl-lpgate013
                  1538420046 23 202719carl-lpgate013
                  1538420166 19 202719carl-lpgate013
                  1538420166 23 202719carl-lpgate013
                  1538420286 19 202719carl-lpgate013
                  1538420286 23 202719carl-lpgate013
                  1538420406 19 202719carl-lpgate013
                  1538420406 23 202719carl-lpgate013

                  Hope this helps someone else.
                  THis was just a simple test and not an in depth one.

                  Comment

                  Working...