3 发现SNMP OIDs

概述

在这个部分,我们将会在交换机上展示discoverySNMP。

键值

和文件系统和网络接口发现不同,此监控项无需有“snmp.discovery” 密钥 - 监控项类型的SNMP agent就足够了。

从Zabbix server/proxy 2.0开始支持发现SNMP OIDs。

根据以下操作来设置发现规则:

  • 前往: 配置模板

  • 点击相应模板中的发现

3 发现SNMP OIDs - 图1

  • 点击屏幕右上角的 创建发现规则

  • 填写发现规则表单,如下面的屏幕截图所示

3 发现SNMP OIDs - 图2

所有必填输入字段都标有红色星号。

要发现的OID在SNMP OID字段中以以下格式定义: discovery[{#MACRO1}, oid1, {#MACRO2}, oid2, …,]

其中 {#MACRO1}, {#MACRO2} … 是有效的LLD宏名称, oid1, oid2… 是能够为这些宏生成有意义值的OID。 包含已发现OID索引的内置宏 {#SNMPINDEX}将应用于已发现的实体。发现的实体按{#SNMPINDEX}宏的值分组。

为了理解我们的意思,让我们在我们的交换机上展示一些snmpwalks:

  1. $ snmpwalk -v 2c -c public 192.168.1.1 IF-MIB::ifDescr
  2. IF-MIB::ifDescr.1 = STRING: WAN
  3. IF-MIB::ifDescr.2 = STRING: LAN1
  4. IF-MIB::ifDescr.3 = STRING: LAN2
  5. $ snmpwalk -v 2c -c public 192.168.1.1 IF-MIB::ifPhysAddress
  6. IF-MIB::ifPhysAddress.1 = STRING: 8:0:27:90:7a:75
  7. IF-MIB::ifPhysAddress.2 = STRING: 8:0:27:90:7a:76
  8. IF-MIB::ifPhysAddress.3 = STRING: 8:0:27:2b:af:9e

然后设置SNMP OID到: discovery[{#IFDESCR}, ifDescr, {#IFPHYSADDRESS}, ifPhysAddress]

现在,此规则将发现将{#IFDESCR} 宏设置为 WAN, LAN1 and LAN2, {#IFPHYSADDRESS} 宏设置为 8:0:27:90:7a:75, 8:0:27:90:7a:76, 和 8:0:27:2b:af:9e, {#SNMPINDEX} 宏设置为发现的OID索引 1, 2 and 3:

  1. {
  2. "data": [
  3. {
  4. "{#SNMPINDEX}": "1",
  5. "{#IFDESCR}": "WAN",
  6. "{#IFPHYSADDRESS}": "8:0:27:90:7a:75"
  7. },
  8. {
  9. "{#SNMPINDEX}": "2",
  10. "{#IFDESCR}": "LAN1",
  11. "{#IFPHYSADDRESS}": "8:0:27:90:7a:76"
  12. },
  13. {
  14. "{#SNMPINDEX}": "3",
  15. "{#IFDESCR}": "LAN2",
  16. "{#IFPHYSADDRESS}": "8:0:27:2b:af:9e"
  17. }
  18. ]
  19. }

如果一个实体没有一个具体的OID,则该实体将省略相应的宏。例如我们有以下数据:

  1. ifDescr.1 "Interface #1"
  2. ifDescr.2 "Interface #2"
  3. ifDescr.4 "Interface #4"
  4. ifAlias.1 "eth0"
  5. ifAlias.2 "eth1"
  6. ifAlias.3 "eth2"
  7. ifAlias.5 "eth4"

然后在在SNMP发现discovery[{#IFDESCR}, ifDescr, {#IFALIAS}, ifAlias] 将会反馈以下结构:

  1. {
  2. "data": [
  3. {
  4. "{#SNMPINDEX}": 1,
  5. "{#IFDESCR}": "Interface #1",
  6. "{#IFALIAS}": "eth0"
  7. },
  8. {
  9. "{#SNMPINDEX}": 2,
  10. "{#IFDESCR}": "Interface #2",
  11. "{#IFALIAS}": "eth1"
  12. },
  13. {
  14. "{#SNMPINDEX}": 3,
  15. "{#IFALIAS}": "eth2"
  16. },
  17. {
  18. "{#SNMPINDEX}": 4,
  19. "{#IFDESCR}": "Interface #4"
  20. },
  21. {
  22. "{#SNMPINDEX}": 5,
  23. "{#IFALIAS}": "eth4"
  24. }
  25. ]
  26. }

监控项原型

以下截屏说明了我们如何在监控项原型中使用这些宏:

3 发现SNMP OIDs - 图3

重复一下,根据需求数量创建监控项原型:

3 发现SNMP OIDs - 图4

触发器原型

以下截屏说明了我们如何在触发器原型中使用这些宏:

3 发现SNMP OIDs - 图5

3 发现SNMP OIDs - 图6

图表原型

以下截屏说明了我们如何在图表原型中使用这些宏:

3 发现SNMP OIDs - 图7

3 发现SNMP OIDs - 图8

我们发现规则的总结:

3 发现SNMP OIDs - 图9

发现实体

当server运行时,它会基于SNMP发现规则的反馈的价值,创建真实的监控项,触发器和图表。在主机配置中,它们的前缀是橙色链接,指向它们来自的发现规则。

3 发现SNMP OIDs - 图10

3 发现SNMP OIDs - 图11

3 发现SNMP OIDs - 图12

3 Discovery of SNMP OIDs

Overview

In this section we will perform an SNMP discovery on a switch.

Item key

Unlike with file system and network interface discovery, the item does not necessarily has to have an “snmp.discovery” key - item type of SNMP agent is sufficient.

Discovery of SNMP OIDs is supported since Zabbix server/proxy 2.0.

To configure the discovery rule, do the following:

  • Go to: ConfigurationTemplates

  • Click on Discovery in the row of an appropriate template

3 发现SNMP OIDs - 图13

  • Click on Create discovery rule in the upper right corner of the screen

  • Fill in the discovery rule form with the required details as in the screenshot below

3 发现SNMP OIDs - 图14

All mandatory input fields are marked with a red asterisk.

The OIDs to discover are defined in SNMP OID field in the following format: discovery[{#MACRO1}, oid1, {#MACRO2}, oid2, …,]

where {#MACRO1}, {#MACRO2} … are valid lld macro names and oid1, oid2… are OIDs capable of generating meaningful values for these macros. A built-in macro {#SNMPINDEX} containing index of the discovered OID is applied to discovered entities. The discovered entities are grouped by {#SNMPINDEX} macro value.

To understand what we mean, let us perform few snmpwalks on our switch:

  1. $ snmpwalk -v 2c -c public 192.168.1.1 IF-MIB::ifDescr
  2. IF-MIB::ifDescr.1 = STRING: WAN
  3. IF-MIB::ifDescr.2 = STRING: LAN1
  4. IF-MIB::ifDescr.3 = STRING: LAN2
  5. $ snmpwalk -v 2c -c public 192.168.1.1 IF-MIB::ifPhysAddress
  6. IF-MIB::ifPhysAddress.1 = STRING: 8:0:27:90:7a:75
  7. IF-MIB::ifPhysAddress.2 = STRING: 8:0:27:90:7a:76
  8. IF-MIB::ifPhysAddress.3 = STRING: 8:0:27:2b:af:9e

And set SNMP OID to: discovery[{#IFDESCR}, ifDescr, {#IFPHYSADDRESS}, ifPhysAddress]

Now this rule will discover entities with {#IFDESCR} macros set to WAN, LAN1 and LAN2, {#IFPHYSADDRESS} macros set to 8:0:27:90:7a:75, 8:0:27:90:7a:76, and 8:0:27:2b:af:9e, {#SNMPINDEX} macros set to the discovered OIDs indexes 1, 2 and 3:

  1. {
  2. "data": [
  3. {
  4. "{#SNMPINDEX}": "1",
  5. "{#IFDESCR}": "WAN",
  6. "{#IFPHYSADDRESS}": "8:0:27:90:7a:75"
  7. },
  8. {
  9. "{#SNMPINDEX}": "2",
  10. "{#IFDESCR}": "LAN1",
  11. "{#IFPHYSADDRESS}": "8:0:27:90:7a:76"
  12. },
  13. {
  14. "{#SNMPINDEX}": "3",
  15. "{#IFDESCR}": "LAN2",
  16. "{#IFPHYSADDRESS}": "8:0:27:2b:af:9e"
  17. }
  18. ]
  19. }

If an entity does not have the specified OID, then the corresponding macro will be omitted for this entity. For example if we have the following data:

  1. ifDescr.1 "Interface #1"
  2. ifDescr.2 "Interface #2"
  3. ifDescr.4 "Interface #4"
  4. ifAlias.1 "eth0"
  5. ifAlias.2 "eth1"
  6. ifAlias.3 "eth2"
  7. ifAlias.5 "eth4"

Then in this case SNMP discovery discovery[{#IFDESCR}, ifDescr, {#IFALIAS}, ifAlias] will return the following structure:

  1. {
  2. "data": [
  3. {
  4. "{#SNMPINDEX}": 1,
  5. "{#IFDESCR}": "Interface #1",
  6. "{#IFALIAS}": "eth0"
  7. },
  8. {
  9. "{#SNMPINDEX}": 2,
  10. "{#IFDESCR}": "Interface #2",
  11. "{#IFALIAS}": "eth1"
  12. },
  13. {
  14. "{#SNMPINDEX}": 3,
  15. "{#IFALIAS}": "eth2"
  16. },
  17. {
  18. "{#SNMPINDEX}": 4,
  19. "{#IFDESCR}": "Interface #4"
  20. },
  21. {
  22. "{#SNMPINDEX}": 5,
  23. "{#IFALIAS}": "eth4"
  24. }
  25. ]
  26. }

Item prototypes

The following screenshot illustrates how we can use these macros in item prototypes:

3 发现SNMP OIDs - 图15

Again, creating as many item prototypes as needed:

3 发现SNMP OIDs - 图16

Trigger prototypes

The following screenshot illustrates how we can use these macros in trigger prototypes:

3 发现SNMP OIDs - 图17

3 发现SNMP OIDs - 图18

Graph prototypes

The following screenshot illustrates how we can use these macros in graph prototypes:

3 发现SNMP OIDs - 图19

3 发现SNMP OIDs - 图20

A summary of our discovery rule:

3 发现SNMP OIDs - 图21

Discovered entities

When server runs, it will create real items, triggers and graphs based on the values the SNMP discovery rule returns. In the host configuration they are prefixed with an orange link to a discovery rule they come from.

3 发现SNMP OIDs - 图22

3 发现SNMP OIDs - 图23

3 发现SNMP OIDs - 图24