[ZBXNEXT-5396] Binary to integer conversion Created: 2019 Sep 02  Updated: 2021 Oct 14  Resolved: 2021 Oct 14

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Server (S)
Affects Version/s: 4.0.12
Fix Version/s: None

Type: Change Request Priority: Trivial
Reporter: Pascal Uhlmann Assignee: Unassigned
Resolution: Won't fix Votes: 0
Labels: functions, item, preprocessing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Sometimes a device provides some information in form of a bitmask. To check some of the bits one could use the trigger function "band". But this function only supports integers why the binary value has to be converted into an unsigned integer.

Unfortunately the item value preprocessing doesn't provide such a functionality. So it would be very helpful if this will be implemented.



 Comments   
Comment by Alexei Vladishev [ 2020 Feb 07 ]

For now you you may consider using JavaScript in pre-processing.

Comment by Pascal Uhlmann [ 2020 Feb 07 ]

I just tested it with Zabbix 4.4.5 and got it working with the following JS code:

 

// JavaScript function to convert a bitmask string
// into an unsigned integer value
function (value) {
  var regex = new RegExp('^[0-1]+$');
  if (value.match(regex) === null) {
    throw "Value '" + value + "' is not a valid bitmask";
  }
  return parseInt(value, 2);
}

So I agree that with JavaScript preprocessing Zabbix doesn't need to provide such a function by itself.

 

Comment by Alexei Vladishev [ 2021 Oct 14 ]

Great, I am closing this ticket.

Generated at Thu Apr 03 07:01:36 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.