環境は,Ubuntu 20.04で検証した.
SNMPのパッケージをインストールする.
sudo apt install snmp
SNMPの基本は以下の記事を参照する.
snmpwalkでsnmpのデータを見てみる.以下では192.168.0.1の機器のsystemを参照している.
snmpwalk -v 2c -c public 192.168.0.1 system
オプション | 意味 |
---|---|
-v | SNMPのバージョン (例:1, 2c, 3) |
-c | コミュニティ名 (例:public) |
MIBが不足していると以下のメッセージが出る.
Cannot find module (XXX) At line X in (none)
まずは /etc/snmp/snmp.conf を修正する.コメントを読むと mibs :
をコメントアウトする必要があると分かる.
# As the snmp packages come without MIB files due to license reasons, loading
# of MIBs is disabled by default. If you added the MIBs you can reenable
# loading them by commenting out the following line.
mibs :
# If you want to globally change where snmp libraries, commands and daemons
# look for MIBS, change the line below. Note you can set this for individual
# tools with the -M option or MIBDIRS environment variable.
#
# mibdirs /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
以下に変更し,保存する.
# As the snmp packages come without MIB files due to license reasons, loading# of MIBs is disabled by default. If you added the MIBs you can reenable
# loading them by commenting out the following line.
# mibs :
# If you want to globally change where snmp libraries, commands and daemons
# look for MIBS, change the line below. Note you can set this for individual
# tools with the -M option or MIBDIRS environment variable.
#
# mibdirs /usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
それでも解決しなければ,以下の記事をもとにMIBS DownloaderをインストールしてMIBをダウンロードする.
Installing MIB in Ubuntu and Solving the Error “SNMP Cannot Find Module …” – IT Blog
sudo apt install snmp-mibs-downloader
以下のコマンドでMIBをダウンロードする.
sudo download-mibs
参考資料
- SNMP関連のコマンドの使い方
- SNMPの基本知識
- Ubuntu でSNMPを使うときのTips
- ネットワーク機器のMIBとOIDを調べる場合