3
6

More than 1 year has passed since last update.

UbuntuでSNMPを使う

Last updated at Posted at 2022-10-20

環境は,Ubuntu 20.04で検証した.

SNMPのパッケージをインストールする.

sudo apt install snmp

SNMPの基本は以下の記事を参照する.

SNMPの基本的なこと - Qiita

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

参考資料

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6