title: How to read SNMP OID Output (bits)
body: <p>I have a quick question. Its most likely user error so I apologize before I begin.</p>
  
  <p>I’m trying to setup threshold for a device so that it will alert us when one of our printers is in a certain state. (Jammed, out of toner, no paper etc) I’ve found the specific oid that handles this. (1.3.6.1.2.1.25.3.5.1.2.1) The specific oid is called hrPrinterDetectedErrorState under the HOST-RESOURCE-MIB. I’ve verified that I can see the oid via SNMPWALK. My problem is interpreting the data its spitting out. What i'm reading in the MIB and what i'm seeing via SNMPWALK are different.</p>
  
  <p>Here is the description of oid from the MIB:</p>
  
  <pre><code>     "This object represents any error conditions detected
        by the printer.  The error conditions are encoded as
        bits in an octet string, with the following
        definitions:
  
              Condition        Bit #
  
              lowPaper              0
  
              noPaper              1
              lowToner              2
              noToner              3
              doorOpen              4
              jammed                5
              offline              6
              serviceRequested      7
              inputTrayMissing      8
              outputTrayMissing    9
              markerSupplyMissing  10
              outputNearFull      11
              outputFull          12
              inputTrayEmpty      13
              overduePreventMaint  14
  
        Bits are numbered starting with the most significant
        bit of the first byte being bit 0, the least
        significant bit of the first byte being bit 7, the
        most significant bit of the second byte being bit 8,
        and so on.  A one bit encodes that the condition was
        detected, while a zero bit encodes that the condition
        was not detected.
  
        This object is useful for alerting an operator to
        specific warning or error conditions that may occur,
        especially those requiring human intervention."
  </code></pre>
  
  <p>The odd part is that SNMPWALK says the oid is a Hex-String while the MIB specifies that it should be a Octet-String. Are the two different? Do I need to convert the data that is output by SNMPWALK somehow to get it to match up with what the MIB is saying?</p>
  
  <p>To test everything, I put the printer into several different “States.” I then ran an SNMPWALK on the device to see what the oid output. Here are the results. As you will see, these results don’t match up to what the MIB specifies.</p>
  
  <pre><code>Case 1: Opened the toner door
  
  Expected Output based on MIB: 4
  SNMP Output: 08
  
  Case 2: Removed Toner &amp; Closed the door
  
  Expected Output based on MIB:  1
  SNMP Output:  10
  
  Case 3: Placed 1 sheet of paper and printed a 2 page document. The printer ran out of paper.
  
  Expected Output based on MIB: 0 or 1
  SNMP Output: @
  </code></pre>
  
  <p>I’m confused at the output. I just need to know how to read the oid so I can setup thresholds so that when it sees, for example, a 08 it performs a certain action.</p>
  
  <p>Thanks for your help!</p>