Calculated checks

Calculated items are items calculated based on data of one or more already existing items in the Zabbix database. All calculations are handled by the Zabbix server and will never be calculated on the agent or the proxy.

Getting ready

If you want to do this exercise, then you need a Zabbix server that is properly setup and linked to the standard Linux template. Of course, you can alter the items that we have used and use your own if you like.

How to do it…

  1. The first step is to go to the Zabbix server and create a new item on the host or in a template.
  2. Give the item a name, something such as % free on root.
  3. Select the Type, Calculated.
  4. Fill in the Key with a unique name, example free.root.
  5. In the field Formula, we add:
    100*last("vfs.fs.size[/,free]",0)/last("vfs.fs.size[/,total ]",0)
  6. Select Numeric (float) as Type of information.
  7. And in the Units field, place %.
  8. Those are the options we need to build our calculated item, so you can save it or give it an application first.
    How to do it…
  9. Next we can go to Monitoring | Latest data to have a look at our new item.
    How to do it…

How it works

A calculated item will calculate a new value from one or more items that already exist in the database. This means that the Zabbix server will calculate a new value of already existing data and create a new item for it.

In our case, we calculated the percentage of the free space on / by dividing the free space from our root filesystem with the total size from our root filesystem and then we multiplied the data hundred times. The last option in our example makes sure that we use only the latest data from our two items.

When we create calculated items, we always need a function, key and optionally some parameters:

func(<key>|<hostname:key>,<parameter1>,...)

There's more...

We can make use of many different functions and are not limited to just the latest data. For instance, we can make use of avg, count, max, min, sum, and so on.

For a complete overview, have a look at this page in the Zabbix documentation.

https://www.zabbix.com/documentation/2.4/manual/appendix/triggers/functions.

Tip

We can only use calculated items on numeric values. Here is no support for strings as yet.

..................Content has been hidden....................

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