4 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

4 Discovery of SNMP OIDs - 图1

  • 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

4 Discovery of SNMP OIDs - 图2

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. {
  3. "{#SNMPINDEX}": "1",
  4. "{#IFDESCR}": "WAN",
  5. "{#IFPHYSADDRESS}": "8:0:27:90:7a:75"
  6. },
  7. {
  8. "{#SNMPINDEX}": "2",
  9. "{#IFDESCR}": "LAN1",
  10. "{#IFPHYSADDRESS}": "8:0:27:90:7a:76"
  11. },
  12. {
  13. "{#SNMPINDEX}": "3",
  14. "{#IFDESCR}": "LAN2",
  15. "{#IFPHYSADDRESS}": "8:0:27:2b:af:9e"
  16. }
  17. ]

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. {
  3. "{#SNMPINDEX}": 1,
  4. "{#IFDESCR}": "Interface #1",
  5. "{#IFALIAS}": "eth0"
  6. },
  7. {
  8. "{#SNMPINDEX}": 2,
  9. "{#IFDESCR}": "Interface #2",
  10. "{#IFALIAS}": "eth1"
  11. },
  12. {
  13. "{#SNMPINDEX}": 3,
  14. "{#IFALIAS}": "eth2"
  15. },
  16. {
  17. "{#SNMPINDEX}": 4,
  18. "{#IFDESCR}": "Interface #4"
  19. },
  20. {
  21. "{#SNMPINDEX}": 5,
  22. "{#IFALIAS}": "eth4"
  23. }
  24. ]

Item prototypes

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

4 Discovery of SNMP OIDs - 图3

Again, creating as many item prototypes as needed:

4 Discovery of SNMP OIDs - 图4

Trigger prototypes

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

4 Discovery of SNMP OIDs - 图5

4 Discovery of SNMP OIDs - 图6

Graph prototypes

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

4 Discovery of SNMP OIDs - 图7

4 Discovery of SNMP OIDs - 图8

A summary of our discovery rule:

4 Discovery of SNMP OIDs - 图9

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.

4 Discovery of SNMP OIDs - 图10

4 Discovery of SNMP OIDs - 图11

4 Discovery of SNMP OIDs - 图12