大网数据广告活动
服务器运维问答

SNMP MIBs on Ubuntu - error in MIBs

· 52CE 我爱测

I'm concerned that the definitive set of MIB files for Ubuntu seems to have syntactic errors. Am I using the wrong MIBs? I have used sudo apt-get install snmp-mibs-downloader sudo download-mibs to install an extensive set of MIBs…

问题原文

原帖链接 · djna · CC BY-SA 4.0

I'm concerned that the definitive set of MIB files for Ubuntu seems to have syntactic errors. Am I using the wrong MIBs?

I have used

sudo apt-get install snmp-mibs-downloader    
sudo download-mibs

to install an extensive set of MIBs that seem to work well, I can snmpwalk and snmptranslate pretty much as expected. However I see a few errors each time I run those commands indicating that the MIBs have a few syntactic errors.

Bad operator (INTEGER): At line 73 in /usr/share/mibs/ietf/SNMPv2-PDU
Unlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 }
Undefined identifier: mib-2 near line 18 of /usr/share/mibs/ietf/IPATM-IPMC-MIB
Expected "::=" (RFC5644): At line 493 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Expected "{" (EOF): At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Bad object identifier: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
Bad parse of OBJECT-IDENTITY: At line 651 in /usr/share/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB

Taking just one example:

Unlinked OID in IPATM-IPMC-MIB: marsMIB ::= { mib-2 57 }

the error here is that mib-2 is missing from the Imports.

While I could try to work my way through and fix these errors, I'm concerned that I'm not using the correct MIBs. Surely these errors shouldn't be occurring?

My snmp.conf has

mibs +ALL

I think this is necessary, if as some advise we comment that line out we don't seem to get the full set of OIDs when walking the tree.

已采纳解答

原帖链接 · telcoM · CC BY-SA 4.0

Which version of Ubuntu are you using?

Ubuntu probably gets its snmp-mibs-downloader package from Debian, and Debian is very strict about redistributability, so the snmp-mibs-downloader gets its MIBs from public sources, including the actual RFCs and other standards documents in the internet.

However, some of those standards documents contain typos and other errors... and in some cases, fixing those would apparently require issuing a completely new revision of the appropriate standards document. And that would take considerable time and effort. (There may be official errata documents instead, but those are not necessarily in a format suitable for automatic patching.)

In Debian, the current version of snmp-mibs-downloader includes a .diff file that is applied to fix a number of errors in various RFC-based MIBs, but it was not always so. The list of errors you included looks familiar to me...

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=584657

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689483

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=689485

All these and more were fixed in version 1.1+nmu1 of snmp-mib-downloader, which was originally released in September 2016. If you're using a version older than that, and there is no update available for your version of Ubuntu, consider downloading the MIBs on some other computer that has a newer version of the package, and then copying the resulting fixed MIBs to wherever you need them.

After that, there should be just one error left:

Bad operator (INTEGER): At line 73 in /usr/share/snmp/mibs/ietf/SNMPv2-PDU

This webpage has a link to a pastebin containing a fixed SNMPv2-PDU MIB file. The modification just replaces the named constant integer value max-bindings with its actual numeric value and comments out the constant definition, and likewise adjusts the definition of BulkPDU to be completely self-contained. Those changes make the net-snmp MIB parser happy.

In case the pastebin goes away, here are the changes in the form of a diff -u output:

--- SNMPv2-PDU~ 2018-06-05 01:59:07.087962230 +0300
+++ SNMPv2-PDU  2018-06-05 02:18:02.146443255 +0300
@@ -70,7 +70,7 @@

 Report-PDU ::= [8] IMPLICIT PDU

-max-bindings INTEGER ::= 2147483647
+-- max-bindings INTEGER ::= 2147483647

 PDU ::= SEQUENCE {
         request-id INTEGER (-214783648..214783647),
@@ -97,7 +97,7 @@
                 inconsistentName(18)
             },
         error-index                 -- sometimes ignored
-            INTEGER (0..max-bindings),
+            INTEGER (0..2147483647),
         variable-bindings           -- values are sometimes ignored
             VarBindList
     }
@@ -105,10 +105,11 @@
 BulkPDU ::=                         -- must be identical in
     SEQUENCE {                      -- structure to PDU
         request-id      INTEGER (-214783648..214783647),
-        non-repeaters   INTEGER (0..max-bindings),
-        max-repetitions INTEGER (0..max-bindings),
+        non-repeaters   INTEGER (0..2147483647),
+        max-repetitions INTEGER (0..2147483647),
         variable-bindings           -- values are ignored
-            VarBindList
+            -- VarBindList
+           SEQUENCE (SIZE (0..2147483647)) OF VarBind
     }

 -- variable binding
@@ -128,6 +129,6 @@

 -- variable-binding list

-VarBindList ::= SEQUENCE (SIZE (0..max-bindings)) OF VarBind
+-- VarBindList ::= SEQUENCE (SIZE (0..2147483647)) OF VarBind

 END

Alternatively you can just delete the SNMPv2-PDU MIB file, since it's just a formal definition of SNMPv2 protocol data units, and that definition is already built-in to most SNMP tools.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-10-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。