概要
この記事では、CiscoのOID 1.3.6.1.4.1.9.9.10.1.3.0.3
を例として、MIB objectに変換する手順を残します。
環境
OS: Ubuntu 22.04
snmpパッケージがインストール済みの状態です。
現在の状態
OID 1.3.6.1.4.1.9.9.10.1.3.0.3
をsnmptranslateしても下記のようにMIB objectに変換されないため、変換されることをゴールとします。
$ snmptranslate 1.3.6.1.4.1.9.9.10.1.3.0.3
SNMPv2-SMI::enterprises.9.9.10.1.3.0.3
MIBを探す
まずはどのMIBが必要なのかを特定する必要があるため、こちらのページから、1.3.6.1.4.1.9.9.10.1.3.0.3
と入力し、OIDs
を選択した上で、検索します。
MIBのURLがわかるので、マシンにてダウンロードします。
$ curl -OL https://www.circitor.fr/Mibs/Mib/C/CISCO-FLASH-MIB.mib
MIBを格納
ディレクトリを任意の名前で作成し、そこへダウンロードしたMIBを格納します。
$ sudo mkdir /usr/share/snmp/private-mibs
$ sudo mv CISCO-FLASH-MIB.mib /usr/share/snmp/private-mibs
MIBのPathを設定
/etc/snmp/snmp.confを編集します。(snmpd.confではないことに注意)
変更箇所は2点です。
- 4行目:
mibs all
とします。 - 10行目:
mibdirs
に、先ほど作成したMIB格納用ディレクトリのPathを追加します。
$ cat -n /etc/snmp/snmp.conf
1 # As the snmp packages come without MIB files due to license reasons, loading
2 # of MIBs is disabled by default. If you added the MIBs you can reenable
3 # loading them by commenting out the following line.
4 mibs all
5
6 # If you want to globally change where snmp libraries, commands and daemons
7 # look for MIBS, change the line below. Note you can set this for individual
8 # tools with the -M option or MIBDIRS environment variable.
9 #
10 mibdirs /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/snmp/private-mibs
変換確認
MIBの導入を終えたので、再度snmptranslateコマンドを実行しOIDが変換されるかどうかを確認します。
下記のようなエラーが出力される場合、依存関係により追加のMIBの導入が必要になります。
今回の場合では、CISCO-QOS-PIB-MIB
とCISCO-SMI
が存在しないという内容が表示されています。
$ snmptranslate 1.3.6.1.4.1.9.9.10.1.3.0.3
MIB search path: /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/snmp/private-mibs
Cannot find module (CISCO-QOS-PIB-MIB): At line 43 in /usr/share/snmp/private-mibs/CISCO-FLASH-MIB.mib
Cannot find module (CISCO-SMI): At line 45 in /usr/share/snmp/private-mibs/CISCO-FLASH-MIB.mib
Did not find 'Percent' in module #-1 (/usr/share/snmp/private-mibs/CISCO-FLASH-MIB.mib)
Did not find 'ciscoMgmt' in module #-1 (/usr/share/snmp/private-mibs/CISCO-FLASH-MIB.mib)
Unlinked OID in CISCO-FLASH-MIB: ciscoFlashMIB ::= { ciscoMgmt 10 }
Undefined identifier: ciscoMgmt near line 48 of /usr/share/snmp/private-mibs/CISCO-FLASH-MIB.mib
Bad operator (INTEGER): At line 73 in /usr/share/snmp/mibs/ietf/SNMPv2-PDU
Cannot adopt OID in CISCO-FLASH-MIB: ciscoFlashPartitionLowSpaceRecoveryNotif ::= { ciscoFlashMIBTraps 10 }
---長いため以下省略---
ダウンロードしたいMIBはわかっているので、今度はこちらのページにアクセスし、CISCO-QOS-PIB-MIB
やCISCO-SMI
を検索すると該当のMIBがヒットするので、
先ほどと同様、それらをダウンロードし、ディレクトリに格納します。
$ curl -OL https://www.circitor.fr/Mibs/Mib/C/CISCO-QOS-PIB-MIB.mib
$ curl -OL https://www.circitor.fr/Mibs/Mib/C/CISCO-SMI.mib
$ sudo mv CISCO-QOS-PIB-MIB.mib /usr/share/snmp/private-mibs
$ sudo mv CISCO-SMI.mib /usr/share/snmp/private-mibs
再度snmptranslateを実行すると、
ciscoFlashMiscOpCompletionTrap
というMIB objectに変換することができます。
$ snmptranslate 1.3.6.1.4.1.9.9.10.1.3.0.3
Bad operator (INTEGER): At line 73 in /usr/share/snmp/mibs/ietf/SNMPv2-PDU
CISCO-FLASH-MIB::ciscoFlashMiscOpCompletionTrap
オプション
Bad operator (INTEGER)と表示されてしまうのは、様々なページでも紹介されており、次のwgetコマンドを実行することで、解消することができます。
$ sudo wget http://www.iana.org/assignments/ianaippmmetricsregistry-mib/ianaippmmetricsregistry-mib -O /usr/share/snmp/mibs/iana/IANA-IPPM-METRICS-REGISTRY-MIB
$ sudo wget http://pastebin.com/raw.php?i=p3QyuXzZ -O /usr/share/snmp/mibs/ietf/SNMPv2-PDU
$ sudo wget http://pastebin.com/raw.php?i=gG7j8nyk -O /usr/share/snmp/mibs/ietf/IPATM-IPMC-MIB
$ snmptranslate 1.3.6.1.4.1.9.9.10.1.3.0.3
CISCO-FLASH-MIB::ciscoFlashMiscOpCompletionTrap
参考
https://www.circitor.fr/Mibs/Search.php
https://www.circitor.fr/Mibs/Mibs.php
https://jp7fkf.hatenablog.jp/entry/2017/04/11/163642