Complex conditions

In the action properties, in the Conditions tab, there was also a Type of calculation drop-down at the very top:

It appears when the action has two or more conditions; hence, as far as we are concerned, it was always present; the default action came with two conditions already. Now, let's find out what functionality it offers:

  • And: All the conditions must be true for the action to match
  • Or: It is enough for one condition to be true for the action to match
  • And/Or: Conditions of the same type are evaluated as Or; conditions of different types are evaluated as And
  • Custom expression: Full freedom option—you write a formula to define how the conditions should be evaluated

The first two options are clear enough. And/Or automatically creates the expression and the logic is based on condition types. For example, let's say we have the following conditions:

  • A: Application = MySQL
  • B: Application = PostgreSQL
  • C: Trigger severity = High
  • D: Host group = Database servers

The And/Or option would create a formula: (A or B) and C and D. This works in a lot of situations, but we might add another condition for a Host group, as follows:

  • E: Host group = Production servers
Actual placeholder letters are likely to be different in the Zabbix frontend as the conditions are ordered. Adding or removing a condition can change the letters of the existing conditions—be careful when using custom expressions and when conditions are changed.

The formula would be (A or B) and C and (D or E). The new Host group condition, being the same type, is or-ed with the previous Host group condition. It is probably not what the user intended, though. In this case, the desired condition was hosts that are both in the database server and production server groups. The And/or option no longer helps help, so we can use a Custom expression. In this case, we would simply type the formula in the input field provided:

(A or B) and C and (D and E) 

Grouping for D and E here is optional; we added it only for clarity.

The situation is even more complicated when negating a number of conditions. If you would like to skip an action in case a problem occurs for a host in either group A or group B, having two not host group conditions such as (A and B) wouldn't work; it would only match if a host was in both groups at the same time. Making the expression check for (A or B) would match unless a host is in both host groups again. For example, if the problem happens on a host that's in group A, Zabbix would check that the host matched the first condition. It would tell that the action shouldn't be performed, but there's the second part including or. The host wouldn't be part of group B, and thus the action would be performed. Unfortunately, there's no simple solution for such cases. Creating two actions, each only negating a single host group, would work.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.200.86