我有一个简单的问题。它最可能的用户错误,所以我开始之前道歉。如何读取SNMP OID输出
我正在尝试设置设备的阈值,以便在我们的某台打印机处于特定状态时它会提醒我们。 (卡住了,没有墨粉,没有纸张等)我找到了处理这个问题的具体oid。 (1.3.6.1.2.1.25.3.5.1.2.1)在HOST-RESOURCE-MIB下,特定的oid被称为hrPrinterDetectedErrorState。我已验证我可以通过SNMPWALK查看oid。我的问题是解释它吐出的数据。我在MIB中读取的内容以及通过SNMPWALK看到的内容不同。
这里是OID从MIB的描述:
"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."
奇数部分是snmpwalk的说,OID是一个十六进制字符串而MIB指定它应该是一个字节串。这两个不同?我是否需要以某种方式转换由SNMPWALK输出的数据以使其与MIB所说的内容相匹配?
为了测试一切,我把打印机放到了几个不同的“状态”中。然后我在设备上运行了一个SNMPWALK来查看oid输出的内容。结果如下。如您所见,这些结果与MIB指定的内容不匹配。
Case 1: Opened the toner door
Expected Output based on MIB: 4
SNMP Output: 08
Case 2: Removed Toner & 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: @
我对输出感到困惑。我只需要知道如何阅读oid,这样我就可以设置阈值,以便当它看到时,例如,它会执行某个操作。
感谢您的帮助!
还没有得到它,所以我必须先将08转换为二进制格式,对不对? “08”是十六进制格式,对不对?所以转换的结果是00001000,但第二个字节在哪里?那么我应该使用设置为1的位数?但是,如果我的打印机返回SNMP 9104,该怎么办?它给了我一个二进制10010001 00000100,我该怎么办? – whizzzkey 2014-11-24 22:34:53
eddited我的回答 – Vajura 2014-11-25 06:20:29
我认为在“SNMP Output:08”的情况下,你只接收一个字节,从左到右解释“00001000”。 – js2010 2018-02-22 22:29:17