在Ubuntu中使用SNMP

这个环境是在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
选项含义 -vSNMP 版本(如 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。

在Ubuntu中安装MIB并解决“SNMP找不到模块…”错误的问题 – IT博客

sudo apt install snmp-mibs-downloader

可以使用以下指令下载MIB文件。

sudo download-mibs

以下是可以作为参考的资料。

    • 如何使用 SNMP 相关命令

snmptranslate – mib mib oid 和名称转换 – 美味的博客

SNMP基础知识

SNMP 基础知识。 – Qiita

在 Ubuntu 上使用 SNMP 的提示

Installing MIB in Ubuntu and Solving the Error “SNMP Cannot Find Module …” – IT Blog

何时查询网络设备的 MIB 和 OID

网络设备的 SNMP MIB/OID 摘要 – Qiita

广告
将在 10 秒后关闭
bannerAds