Ad Widget

Collapse

Checking status bits in trigger expressions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikkello
    Junior Member
    • Jun 2007
    • 8

    #1

    Checking status bits in trigger expressions

    Is it possible to check the individual status bits of an numeric item, in a trigger expression?

    I would like to monitor a printer (via SNMP), and when the hrDeviceStatus says Warning or Down, the actual error status can be read in hrPrinterDetectedErrorState, where bit 0 = lowPaper, bit 1 = noPaper, bit 2 = lowToner, etc.

    Can I somehow extract this information from the item?
  • xs-
    Senior Member
    Zabbix Certified Specialist
    • Dec 2007
    • 393

    #2
    I'd make an item for each OID (devicestatus and errorstate) and create a trigger using both
    If (devicestatus is down or warning) and errorstate is lowpaper then message: Low Paper

    or something like that

    Comment

    • mikkello
      Junior Member
      • Jun 2007
      • 8

      #3
      I would like to do what corresponds to a bit-wise check in the C programming language, since hrPrinterDetectedErrorState can contain any combination of errors / warnings:

      ...
      if (hrPrinterDetectedErrorState & 0x00000001)
      raiseTrigger(lowPaper);
      if (hrPrinterDetectedErrorState & 0x00000010)
      raiseTrigger(noPaper);
      if (hrPrinterDetectedErrorState & 0x00000100)
      raiseTrigger(lowToner);
      ...

      is that possible in Zabbix expressions?

      Comment

      • pach
        Junior Member
        • Jun 2009
        • 6

        #4
        Good morning everyone, I have the same problem, I explain :
        I want to check a printer, so I'm using this MIB entry :
        .1.3.6.1.2.1.25.3.2.1.5.1
        .iso.org.dod.internet.mgmt.mib-2.host.hrDevice.hrDeviceTable.hrDeviceEntry.hrDevi ceStatus.1 = INTEGER: warning(3)

        Problem is that I don't know how to display even "warning" or "3" in Zabbix. It's written it is INTEGER, so in "Type of information", I tried every possibilities but nothing works, I have even "0", "0.00000" or "...".

        Could someone help me please ?

        Thanks a lot

        Comment

        • ingmar
          Junior Member
          • Aug 2010
          • 5

          #5
          Has anyone come up with a solution for this yet? It seems there are no bitwise operators in Zabbix triggers, so integer values where each bit indicates a different state can't be selectively monitored.

          In my case this is also the SNMP hrPrinterDetectedErrorState - some bits like "lowPaper" I don't care about, while others like "serviceRequested" I do want triggers for.

          Any suggestions, even hackish ones?

          Comment

          • mbrassard
            Junior Member
            • Nov 2011
            • 3

            #6
            Quite an old post, but I had the same issue and while searching for a solution, Google returns me this post. Since I had to do a workaround, I decided to put it here for future lost folks.

            Normally, I would do the following to retrieve the value of a bit without binary operations:

            Bit = int(number/2^position)%2

            For example, int(12/2^3)%2 = int(12/8)%2 = int(1.5)%2 = 1%2 = 1 => bit 3 is at 1

            Sadly, the Zabbix arithmetic is too limited to allow such a workaround. In order to achieve something similar, I had to resolve at using an external check or list all values in a big condition.

            If you are under Linux, you can wrap your snmpget with dc in an external script. For example:

            echo "`snmpget [snmp priv info] -OqvtUe <hostname> <OID>` 2 3 ^ / 2 % p" | dc

            Will return 1 if the bit at position 3 is set, 0 otherwise.

            Or you can go with a Zabbix only solution and list all possibilities:

            (val >7 & val<16) | (val>23&val<32) | (var>39&val<48) ... etc.

            0000 1000 (8) ... 0000 1111 (15)
            0001 1000 (24) ... 0001 1111 (31)
            0010 1000 (40) ... 0010 1111 (47)
            ... etc.

            This quickly becomes unusable as the amount of range is 2^(n-x+1), where n is the amount of bits available and x the bit we want to look at. In my example, with 8 bits, looking at the third one gives 16 (2^4) ranges.

            For the OP case, that would be unusable. As per my understanding of the provided link, the bits are numbered backward, with 0 being the msb instead of the lsb like it is normally seen in bitwise operations. This means their bit x is, in fact, bit n-x.

            Hope this helps.
            Last edited by mbrassard; 12-03-2012, 21:11.

            Comment

            • TuXator
              Junior Member
              • Feb 2009
              • 15

              #7
              Originally posted by ingmar
              It seems there are no bitwise operators in Zabbix triggers, so integer values where each bit indicates a different state can't be selectively monitored.
              I've added a feature request for bitwise trigger operators in the Zabbix support tracker:



              Please vote for it, the more votes it gets, the more likely it will be implemented!

              Cheers,
              --leo

              Comment

              Working...