Checking for missing data

Some items are always expected to provide values, such as the CPU load item. The problem condition for this item is usually value too large. But there are some items that are different, for example, an item with the agent.ping key. This item only tells us whether the agent is available to the server, and it only returns 1 when the agent is up. And yes, that's it—it does not send 0 when the agent is down; there is no value at all. We can't write a trigger with the last() function, as the last value is always 1. The same goes for min(), max(), and avg(). Luckily, there is a function we can use in this case: nodata(). It allows the trigger to fire if an item is missing data for some period of time. For example, if we created an agent.ping item on A test host, the trigger could look like this:

{A test host:agent.ping.nodata(300)=1} 

Here, the nodata() function is checking whether this item is missing data for 300 seconds, or 5 minutes. If so, the trigger will fire. What's the comparison with 1? All trigger functions in Zabbix return a number. The nodata() function returns 1 if the item is missing data and 0 if there's at least one value in the specified time period. Note that it might not be a good idea to try and guess what return values are available for a trigger function—if you are not sure, you'd better check the manual for details. To make it easier, I've added the link for you at the end of this chapter, in the Further reading section.

The nodata() function is said to be time-based. Normal trigger functions are evaluated when an item receives a new value. This makes a lot of sense for triggers against items such as the CPU load item we created earlier—when a value arrives, we compare it to the threshold. It wouldn't work that well with our agent.ping item, though. If values were coming in, everything would be good—the trigger expression would be evaluated, and this function would return 0. If values stopped coming in, it would not get evaluated and would never fire. Then, if a new value arrived, the function would get evaluated, would see that new value, and declare that everything was perfect.

So, in this case, the trigger is not evaluated only when a new value comes in. Instead, this function is evaluated every 30 seconds. This interval is hardcoded. To be more specific, any trigger that includes at least one time-based function in the expression is recalculated every 30 seconds. With the 30-second interval, you should never use a parameter lower than 30 for the nodata() function. To be safe, never use a parameter lower than 60 seconds. In Zabbix version 4.0.0, the following trigger functions are time-based:

  • date()
  • dayofmonth()
  • dayofweek()
  • nodata()
  • now()
  • time()

Refer to the Zabbix manual if you're using a later version—there might be changes to this list.

Starting from Zabbix 3.2, nodata(), date(), dayofmonth(), dayofweek(), now(), and time() functions are also calculated for unsupported items. The other functions require the referenced item to be in a supported state.
..................Content has been hidden....................

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