Using LLD on templates in Zabbix

Now, let’s get started on my favorite part of template creation: LLD. I think this is one of the most powerful and most used parts of Zabbix.

Getting ready

To get ready for this recipe, you will need your Zabbix server, the SNMP-monitored host from the previous recipes, and our template from the previous recipe.

A working knowledge of the SNMP tree structure is also recommended. So, make sure to read the Working with SNMP monitoring recipe in Chapter 2, Setting up Zabbix Monitoring, thoroughly.

How to do it…

  1. Let’s get started by navigating to Configuration | Templates and selecting our Template OS Linux by SNMPvX template.
  2. Now, go to Discovery rules, and in the top-right corner, click Create discovery rule. This will lead you to the LLD creation page:
    Figure 4.25 – Zabbix LLD creation page, empty

    Figure 4.25 – Zabbix LLD creation page, empty

    Now, we will be making a discovery rule to discover our interfaces on the Linux host. The Linux SNMP tree for interfaces is at OID 1.3.6.1.2.1.2.

    Important note

    Make sure that Linux net-snmp is configured correctly in the /etc/snmp/snmpd.conf file. It’s important to change the view in this file to show everything from .1 and up, like this: 
view systemview included .1

  3. Now, let’s continue with creating our LLD rule by adding the following to our LLD creation page:
    Figure 4.26 – Zabbix LLD creation page filled with our information for network interface discovery

    Figure 4.26 – Zabbix LLD creation page filled with our information for network interface discovery

  4. After clicking the Add button, we can navigate back to our template at Configuration | Templates and click Template OS Linux by SNMPvX.

    Important note

    We define a Keep lost resources period of 0 days; we do this because this is a test template. This option is used by LLD to remove created resources (like items and triggers) if they are no longer present on our monitored host. Using 0 days can lead to lost resources because we might get a resource back within a set amount of time, so make sure to adjust this value to your production environment’s standard.

  5. Go to Discovery rules and click our newly created rule, Discover Network interfaces.
  6. Now, we will go to Item prototypes and click Create item prototype in the top-right corner. This will take us to the Item prototype creation screen, as shown in the following screenshot:
    Figure 4.27 – Zabbix LLD Item prototype creation page, empty

    Figure 4.27 – Zabbix LLD Item prototype creation page, empty

    Here, we will create our first prototype for creating items from LLD. This means we have to fill it with the information we want our items to contain.

  7. Let’s start by filling in an item prototype for the interface operational status, like this:
    Figure 4.28 – Zabbix LLD item prototype creation page filled with our information for interface operational status

    Figure 4.28 – Zabbix LLD item prototype creation page filled with our information for interface operational status

  8. After clicking the Add button, let’s also add the following item prototype:
    Figure 4.29 – Zabbix LLD item prototype creation page filled with our information for interface admin status

    Figure 4.29 – Zabbix LLD item prototype creation page filled with our information for interface admin status

  9. Last, but not least, move over to the Trigger Prototype page and click the Create trigger prototype button in the top-right corner, and create the following trigger:
Figure 4.30 – Zabbix LLD trigger prototype creation page filled with our information for interface link status

Figure 4.30 – Zabbix LLD trigger prototype creation page filled with our information for interface link status

How it works…

Now, LLD is quite an extensive topic in Zabbix, but by following the steps in this recipe you should be able to build almost every form of LLD there is to configure in Zabbix. First of all, let’s look at how the discovery works.

In the discovery rule, we just configured the following:

Figure 4.31 – Zabbix LLD discovery key and OID for key net.if.discovery

Figure 4.31 – Zabbix LLD discovery key and OID for key net.if.discovery

What we are basically saying here is for every interface after OID .1.3.6.1.2.1.2.2.1.2, fill the {#IFNAME} LLD macro. In our case, this would be the following OIDs:

.1.3.6.1.2.1.2.2.1.2.1 = STRING: lo
.1.3.6.1.2.1.2.2.1.2.2 = STRING: ens192

So, we are saving these for use in our prototypes. Now, when we look at what we did at our Operational status prototype, this all comes together:

Figure 4.32 – Zabbix LLD item prototype name, type, key, and OID

Figure 4.32 – Zabbix LLD item prototype name, type, key, and OID

We are telling our item prototype to create an item for every single {#IFNAME} value using the key defined plus the {#SNMPINDEX} LLD macro. The SNMPINDEX is the last number of our SNMP poll. In this case, we would see the following:

.1.3.6.1.2.1.2.2.1.8.1 = INTEGER: up(1)
.1.3.6.1.2.1.2.2.1.8.2 = INTEGER: up(1)

For all the vendors in the world, there’s a set of predefined SNMP rules they need to abide to. Our first interface entry when polling .1.3.6.1.2.1.2.2.1.2 was the .1 SNMPINDEX with the value lo. This means that when polling .1.3.6.1.2.1.2.2.1.8, the .1 SNMPINDEX here should still contain a value for lo.

Zabbix LLD will now create an item with the name Interface lo: Operational status, which will poll the SNMP OID:

.1.3.6.1.2.1.2.2.1.8.1 = INTEGER: up(1)

It will also create an item with the name Interface ens192: Operational status, which will poll the SNMP OID:

.1.3.6.1.2.1.2.2.1.8.2 = INTEGER: up(1)

The created items will then look like this:

Figure 4.33 – Zabbix latest data screen for our SNMP-monitored host

Figure 4.33 – Zabbix latest data screen for our SNMP-monitored host

Besides creating these LLD items, we also created an LLD trigger prototype. This works in the same manner as item prototypes. If we check our host triggers, we can see two created triggers:

Figure 4.34 – Our SNMP-monitored host triggers

Figure 4.34 – Our SNMP-monitored host triggers

These triggers have been created in the same manner as the items and are then filled with the correct items for triggering on:

Figure 4.35 – Our SNMP-monitored host trigger for ens192

Figure 4.35 – Our SNMP-monitored host trigger for ens192

We can see that for Interface Operation Status we have an SNMPINDEX of 2, and for Interface Admin status as well. Our trigger will now trigger when the Operation status is 0 (DOWN) and our Admin status is 1 (UP).

A neat trigger, to make sure we only have a problem when the Admin status is UP; after all, we want our interface down when we configure it to be Admin DOWN.

Tip

It’s possible to use discovery filters to only add the interfaces that have Admin status UP to our monitoring. This way, we keep our required Zabbix Server performance lower and our data cleaner. Consider using discovery filters for use cases such as this.

It will gives you output similar to below:

It will gives you output similar to below:

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

1 + twenty =