3 MIB files

3 MIB文件

Introduction

介绍

MIB stands for a Management Information Base. MIB files allow you to use textual representation of the OID (Object Identifier).

MIB代表管理信息库。 MIB文件允许您使用OID(对象标识符)的文本表示。

For example, 例如:

  1. ifHCOutOctets

is textual representation of OID

是OID的文本表示

  1. 1.3.6.1.2.1.31.1.1.1.10

You can use either, when monitoring SNMP devices with Zabbix, but if you feel more comfortable when using textual representation you have to install MIB files.

在使用Zabbix监视SNMP设备时,您可以使用其中任何一个,但如果您在使用文本表示时感觉更舒服,则必须安装MIB文件。

Installing MIB files

安装 MIB文件

On Debian-based systems: 在基于Debian的系统上:

  1. # apt install snmp-mibs-downloader
  2. # download-mibs

On RedHat-based systems: 在基于RedHat的系统上:

  1. # yum install net-snmp-libs

Enabling MIB files

启用MIB文件

On RedHat-based systems the mib files should be enabled by default. On Debian-based systems you have to edit file /etc/snmp/snmp.conf and comment out the line that says mibs :

在基于RedHat的系统上,默认情况下应启用mib文件。 在基于Debian的系统上,你必须编辑文件 /etc/snmp/snmp.conf 并注释掉 mibs :的行

  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 :

Testing MIB files

测试MIB文件

Testing snmp MIBs can be done using snmpwalk utility. If you don’t have it installed, use the following instructions.

测试snmp MIB可以使用snmpwalk实用程序完成。 如果未安装,请使用以下说明。

On Debian-based systems: 在基于Debian的系统上:

  1. # apt install snmp

On RedHat-based systems: 在基于RedHat的系统上:

  1. # yum install net-snmp-utils

After that, the following command must not give error when you query a network device: 之后,查询网络设备时,以下命令不得出错:

  1. $ snmpwalk -v 2c -c public <NETWORK DEVICE IP> ifInOctets
  2. IF-MIB::ifInOctets.1 = Counter32: 176137634
  3. IF-MIB::ifInOctets.2 = Counter32: 0
  4. IF-MIB::ifInOctets.3 = Counter32: 240375057
  5. IF-MIB::ifInOctets.4 = Counter32: 220893420
  6. [...]

Used options:

使用选项:

-v 2cuse SNMP protocol version 2c
-c publicspecify SNMP community - “public”

Using MIBs in Zabbix

在Zabbix中使用MIBs

The most important is to keep in mind that Zabbix processes do not get aware of the changes made to MIB files. So after every change you must restart Zabbix server or proxy, e. g.:

最重要的是要记住,Zabbix进程无法了解对MIB文件所做的更改。 因此,每次更改后,您必须重新启动Zabbix服务器或代理,比如:

  1. # service zabbix-server restart

After that, the changes made to MIB files are in effect.

之后,对MIB文件所做的更改将生效。

Using custom MIB files

使用定制化MIB文件

There are standard MIB files coming with every GNU/Linux distribution. But some device vendors provide their own.

每个GNU / Linux发行版都有标准的MIB文件。 但有些设备供应商提供自己的产品。

Let’s say, you would like to use CISCO-SMI MIB file. The following instructions will download and install it:

比方说,您想使用CISCO-SMI MIB文件。 以下说明将下载并安装它:

  1. # wget ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my -P /tmp
  2. # mkdir -p /usr/local/share/snmp/mibs
  3. # grep -q '^mibdirs +/usr/local/share/snmp/mibs' /etc/snmp/snmp.conf 2>/dev/null || echo "mibdirs +/usr/local/share/snmp/mibs" >> /etc/snmp/snmp.conf
  4. # cp /tmp/CISCO-SMI.my /usr/local/share/snmp/mibs

Now you should be able to use it. Try to translate the name of the object ciscoProducts from the MIB file to OID:

现在你应该可以使用它了。 尝试将对象的名称 ciscoProducts 从MIB文件转换为OID:

  1. # snmptranslate -IR -On CISCO-SMI::ciscoProducts
  2. .1.3.6.1.4.1.9.1

If you receive errors instead of the OID, ensure all the previous commands did not return any errors.

如果您收到错误而不是OID,请确保所有以前的命令都没有返回任何错误。

The object name translation worked, you are ready to use custom MIB file. Note the MIB name prefix (CISCO-SMI::) used in the query. You will need this when using command-line tools as well as Zabbix.

对象名称转换有效,您可以使用自定义MIB文件。 请注意查询中使用的MIB名称前缀 (CISCO-SMI::) 。 使用命令行工具和Zabbix时,您将需要这个。

Don’t forget to restart Zabbix server/proxy before using this MIB file in Zabbix.

在Zabbix中使用此MIB文件之前,请不要忘记重新启动Zabbix服务器/代理。

Keep in mind that MIB files can have dependencies. That is, one MIB may require another. In order to satisfy these dependencies you have to install all the affected MIB files.

请记住,MIB文件可以具有依赖项。 也就是说,一个MIB可能需要另一个。 为了满足这些依赖关系,您必须安装所有受影响的MIB文件。