Using the bitwise trigger function

The special band() function is somewhat similar to the simple last() function, but instead of just returning the last value, it applies a bitmask with a bitwise AND to the value and returns the result of this operation. If we wanted to check for the least significant bit, the one that lets us know whether the unit is powered on, we would use a bitmask of 1. Assuming some other bits have been set, we could receive a value of 170 from the monitored system. In binary, that would be 10101010. Bitwise AND would multiply each bit down as shown in the column :

Decimal value

Binary value

Value

170

10101010

Bitwise AND (multiplied down)

Mask

1

00000001

Result

0

00000000

 

The general syntax for the band() trigger function is as follows:

band(#number|seconds,mask) 
It also supports a third parameter, time shift—we discussed time shifts in Chapter 6, Detecting Problems with Triggers.

When thinking about binary representation, we have to use decimal numbers in Zabbix. In this case, it is simple  the trigger expression would be as follows:

{host:item.band(#1,1)}=1 

We are checking the last value received with #1, applying a decimal mask of 1, and verifying whether the last bit is set.

As a more complicated example, let's say we wanted to check for bits (starting from the least significant) 3 and 5, and we received a value of 110 (in decimal):

Decimal value

Binary value

Value

110

01101110

Bitwise AND (multiplied down)

Mask

20

00010100

Result

4

00000100

A simple way to think about the operation of the mask would be that all the bits that match a 0 in the mask are set to 0, and all other bits pass through it as is. In this case, we are interested in whether both bits 3 and 5 are set, so the expression would be as follows:

{host:item.band(#1,20)}=20 

In our value, only bit 3 was set, and the resulting value from the function was 4, which does not match 20—neither bits are set, so the trigger expression evaluates to FALSE. If we wanted to check for bit 3 being set and bit 5 not being set, we would compare the result to 4. And if we wanted to check for bit 3 not being set and bit 5 being set, we would compare it to 16—because in binary that's 00010000.

Now let's get back to checking for the predictive failure bit being set—it was the eighth bit, so, our mask should be 10000000, and we should compare the result to 10000000. But both of these should be in decimal format, so we should set both the mask and comparison values to 128.

Let's create a trigger in the frontend with this knowledge:

  1. Go to Configuration | Hosts, click on Triggers next to IPMI host, and click on Create trigger.
  2. Enter Power unit predictive failure on {HOST.NAME} in the Name field, and then click on Add next to the Expression field.
  3. Click on Select next to the Item field, and then choose Power Unit Stat.
  4. Set the Function drop-down to Bitwise AND of last (most recent) T value and mask = N, enter 128 in both the Mask and N fields, and then click on Insert. The resulting trigger expression should be as follows:
{IPMI host:Power_Unit_Stat.band(,128)}=128 

Notice how the first function parameter is missing? As with the last() function, omitting this parameter is equal to setting it to #1, as in the earlier examples. This trigger expression will ignore the 7 least significant bits and check whether the result is set to 10000000 in binary, or 128 in decimal.

Bitwise comparison is possible with the count() function, too. Here, the syntax is potentially more confusing: both the pattern and mask are to be specified as the second parameter, separated by a slash. If the pattern and mask are equal, the mask can be omitted. Let's try to look at some examples to clear this up.

For example, to count how many values had the eighth bit set during the previous 10 minutes, the function part of the expression would be as follows:

count(10m,128,band) 

Our pattern and mask were the same, so we could omit the mask part. The previous expression is equivalent to the following:

count(10m,128/128,band) 

If we would like to count how many values had bit 5 set and bit 3 not set during the previous 10 minutes, the function part of the expression would be as follows:

count(10,16/20,band) 

Here, the pattern is 16 or 10000, and the mask is 20 or 10100.

Beware of adding too many IPMI items against a single system—it is very easy to overload the IPMI controller.

With the release of Zabbix 4.0, it's now possible to use id: and name: in the IPMI sensor field:
  • name: allows us to specify the sensor by its full name instead of its short name
  • id: gives us the option to specify the ID of the specific sensor we would like to monitor
All of this information can easily be found in the Zabbix server log file. For this, it's best to start the Zabbix server in debug level 4.
..................Content has been hidden....................

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