Ad Widget

Collapse

How to evaluate a single bit in a decimal integer?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sovr
    Junior Member
    • May 2013
    • 6

    #1

    How to evaluate a single bit in a decimal integer?

    Hi everybody,
    I'm using Zabbix 1.8.13 and have an SMTP host which returns its status as an integer which is the decimal encoding of a status bit mask.

    E.g.

    1 = 0001 = memory fault
    2 = 0010 = processor fault
    4 = 0100 = disk fault
    6 = 0110 = disk fault and processor fault
    ...
    etc.
    ...
    Since the host returns an integer (1 or 2 or 4 or 6 in example above) I don't know how to check whether the 2nd bit ('disk fault') is up and then trigger 'disk fault'.

    If it would've returned a string of bit, I would've used a regexp as nilie suggested, but I have no idea how to do with an integer.

    Any help greatly appreciated.
    Thanks,
    Sovr
  • herta
    Senior Member
    • Sep 2011
    • 101

    #2
    Zabbix doesn't have a bitmap item type, so assuming you cannot install a Zabbix agent on the SMTP server or get it to send values that can be handled more easily by the Zabbix server, the best I can think of is check for possible values.

    In the example you gave, there are three things that can go wrong:
    0001 = memory fault
    0010 = processor fault
    0100 = disk fault

    So you could create three triggers. E.g.,
    - "Memory fault" will fire when the item value is either 1, 3 or 5
    - "Processor fault" will fire when the item value is either 2, 3 or 6
    - "Disk fault" will fire when the item value is either 4, 5 or 6

    Not elegant, I know, and you'll need to update all the triggers if a new fault code is added.

    Comment

    • sovr
      Junior Member
      • May 2013
      • 6

      #3
      Thanks a lot for the suggestion.

      Unfortunately the solution is not feasible, because I simplified but actual bit mask is 16 bits so there are simply too many combinations

      Any other idea greatly appreciated

      Comment

      • herta
        Senior Member
        • Sep 2011
        • 101

        #4
        Ouch. 16 bits would indeed make that impracticable.

        Second idea, "slightly" more involved and not tested by me.

        You could try creating a trigger to fire when the value of your item is not 0.

        Then create an action (Cf. Configuration -> Actions) with Event source = Triggers. In the Operations tab, select Operation type "Remote command" and create a custom script to run on the zabbix server. Pass the item value to the script, parse it in the script and send the relevant values back to (16) zabbix items. Then trigger on those items.

        Not sure whether that is more feasible. As I said, it's "slightly" more involved.

        Comment

        • sovr
          Junior Member
          • May 2013
          • 6

          #5
          I solved using an external check.

          Thanks a lot.

          Comment

          • herta
            Senior Member
            • Sep 2011
            • 101

            #6
            Ah, much simpler.

            Thanks for sharing your solution.

            Comment

            Working...