Value preprocessing and dependent items

A new powerful tool added in Zabbix is preprocessing items and dependent items. We touched briefly on preprocessing when we had to add a network card and calculate the Change per second. But there's much more that we can do now out of the box without the need for knowledge of scripting. As value mapping is something we have together in an item, we'll combine it with dependent items as it makes more sense here.

Let's start by creating a new item on our A test host

  • Name: Zabbix master item
  • Type: Zabbix agent(active)
  • Key: mysql.dependent
  • Type of information: Text
  • New applications: MySQL-Master

If all goes well, when we look at the latest data, we now see text value in our history as shown in the following screenshot:

When we click on History, it should show us all of the values from our MySQL:

Now, this looks nice but let's say we're only interested in two lines, Innodb_deadlocks and Aborted_clients, and we want to see the values from those two lines also. It turns out that with the new dependent items and preprocessing, this is going to be a piece of cake. 

Let's go back to our list of items on A test host and click on the three dots (...) before the item, Zabbix master item as shown in the following screenshot:

Now, click on Create dependent item from the pop-up menu that appears. This will create a new item that is dependent on our Zabbix master item:

In our new item that appears, we have to add a few things. Let's start with the easy ones first: 

  • Name: Innodb_deadlocks
  • Type: Dependent item
  • Key: Innodb.deadlocks
  • Type of information: Character
  • New application: MySQL-Dependent

Notice how we now have Master item as an option, and how it's already making a reference to our first item our Zabbix master item:

We still have things to do, as this will not work. We need to tell Zabbix now how to retrieve this information from our master item. This is where our preprocessing comes into play.

Let's go to the Preprocessing tab and add the following information in it:

  • Name: Regular expression
  • Parameters: In the first box, add Innodb_deadlockss(d.*) and in the second box, 1:

Click on Update when done.

Create another dependent item for our Aborted_clients item. This time, use the following information in our item:

  • Name: Aborted_clients
  • Type: Dependent item
  • Key: Aborted.clients
  • Type of information: Character
  • Application: MySQL-Dependent

Just like with the previous item, we need to create a reprocessing step. Use the following information:

  • Name: Regular expression
  • Parameters: In the first box, Aborted_clientss(d.*) and in the second box, 1

When ready click Add, we now should have one master item with two dependent items.

Let's check this by going to Configuration | Hosts, then A test host, and clicking on Items. Open the filter and select MySQL-Master and MySQL-Dependent from the subfilter. We should now see three items, one master and two dependent items, in our item list:

We didn't changed the History of the master item but if you have no need to keep it, then you could change the History to 0 days. The item then will only be used to create the dependent items and no data will be kept in the database.

Now, let's check whether we have some data; let's go to the latest data page and filter on Application by selecting the MySQL-Dependent items from the list:

Yippee! We have two items with values in our latest data page and we had to write 0 lines of code for this. In previous versions, we probably had to write a script to send us data for both items.

As you have probably noticed, there's much more to choose from in our preprocessing options than only Regular expression; some we used already when configuring our network card and others we didn't. Let's have a quick overview of what's possible:

We have the following fields from the previous screenshot:

  • Regular expression: This matches the value to the <pattern> regular expression and replaces the value with <output>. pattern is replaced with a regular expression and output with the formatting template. A N (where N = 1…9) escape sequence is replaced.
  • Trim: This removes specified characters from the beginning and end of the value.
  • Right trim: This removes specified characters from the end of the value.
  • Left trim: This removes specified characters from the beginning of the value.
  • XML XPath: This extracts a value or fragment from XML data using XPath functionality.
  • JSON Path: This extracts a value or fragment from JSON data using a simple subset of JSONPath functionality.
  • Custom multiplier: This multiplies the value by the specified integer or floating-point value.
  • Simple change: This calculates the difference between the current and previous value.
  • Changer per second: This calculates the value change (the difference between the current and previous value) in speed per second.
  • Boolean to decimal: This converts the value from Boolean format into decimal.
  • Octal to decimal: This converts the value from octal format into decimal.
  • Hexadecimal to decimal: This converts the value from hexadecimal format into decimal.
..................Content has been hidden....................

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