Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Zabbix 5 IT Infrastructure Monitoring Cookbook

You're reading from   Zabbix 5 IT Infrastructure Monitoring Cookbook Explore the new features of Zabbix 5 for designing, building, and maintaining your Zabbix setup

Arrow left icon
Product type Paperback
Published in Feb 2021
Publisher Packt
ISBN-13 9781800202238
Length 428 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Brian van Baekel Brian van Baekel
Author Profile Icon Brian van Baekel
Brian van Baekel
Nathan Liefting Nathan Liefting
Author Profile Icon Nathan Liefting
Nathan Liefting
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Chapter 1: Getting Started with Zabbix and User Management 2. Chapter 2: Setting Up Zabbix Monitoring FREE CHAPTER 3. Chapter 3: Working with Triggers and Alerts 4. Chapter 4: Building Your Own Structured Templates 5. Chapter 5: Visualizing Data, Inventory, and Reporting 6. Chapter 6: Using Discovery for Automatic Creation 7. Chapter 7: Setting Up Zabbix Proxies 8. Chapter 8: Integrating Zabbix with External Services 9. Chapter 9: Extending Zabbix Functionality with Custom Scripts and the Zabbix API 10. Chapter 10: Maintaining Your Zabbix Setup 11. Chapter 11: Advanced Zabbix Database Management 12. Chapter 12: Bringing Zabbix to the Cloud with Zabbix Cloud Integration 13. Other Books You May Enjoy

Creating Zabbix simple checks and the Zabbix trapper

In this recipe, we will go over two checks that can help you built some more customized setups. The Zabbix simple checks provide you with an easy way to monitor some specific data. The Zabbix trapper combines with Zabbix sender to get data from your hosts into the server, allowing for some scripting options. Let's get started.

Getting ready

To create these checks, we will need a Zabbix server and a Linux host to monitor. We can use the host with a Zabbix agent and SNMP monitoring from the previous recipes.

Do note for these checks that we do not actually need the Zabbix agent.

How to do it…

Working with simple checks is quite simple, as the name suggests, so let's start.

Creating simple checks

We will create a simple check to monitor whether a service is running and accepting TCP connections on a certain port:

  1. To get this done, we will need to create a new host in Zabbix frontend. Go to Configuration | Hosts in your Zabbix frontend and click Create host in the top-right corner.
  2. Create a host with the following settings:
    Figure 2.17 – Zabbix host configuration page for host lar-book-agent_simple

    Figure 2.17 – Zabbix host configuration page for host lar-book-agent_simple

  3. Now go to Configuration | Hosts, click the newly created host, and go to Items. We want to create a new item here by clicking the Create item button.

    We will create a new item with the following values, and after doing, so we will click the Add button at the bottom of the page:

    Figure 2.18 – Zabbix item port 22 check configuration page for host lar-book-agent_simple

    Figure 2.18 – Zabbix item port 22 check configuration page for host lar-book-agent_simple

    Important note

    We are adding the item key net.tcp.services[SSH,22] here. The port in this case is optional, as we can specify the service SSH with a different port if we would want to.

  4. Now we should be able to see whether our server is accepting SSH connections on port 22 on our Latest data screen. Navigate to Monitoring | Hosts and check the Latest data screen for our new value:
Figure 2.19 – Zabbix Latest data page for host lar-book-agent_simple, item port 22 check

Figure 2.19 – Zabbix Latest data page for host lar-book-agent_simple, item port 22 check

That's all there is to creating your simple checks in Zabbix. Now let's move on to the Zabbix trapper item.

Creating a trapper

We can do some cool stuff with Zabbix trapper items once we get more advanced setups. But for now, let's create an item on our lar-book-agent_simple host:

  1. Go to Configuration | Hosts and click the host, then go to Items. We want to create a new item here again by clicking the Create item button.

    Now let's create the following item and click the Add button:

    Figure 2.20 – Zabbix item trap receiver configuration screen for host lar-book-agent_simple

    Figure 2.20 – Zabbix item trap receiver configuration screen for host lar-book-agent_simple

  2. If we go to the CLI of our monitored server, we can now execute the following to install Zabbix sender:
    dnf install zabbix-sender
  3. After installation, we can use Zabbix sender to send some information to our server:
    zabbix_sender -z 10.16.16.152 -p 10051 -s "lar-book-agent_simple" -k trap -o "Let's test this book trapper"

    Now we should be able to see whether our monitored host has sent out the Zabbix trap and the Zabbix server has received this trap for processing.

  4. Navigate to Monitoring | Hosts and check the Latest data screen for our new value:
Figure 2.21 – Zabbix Latest data page for host lar-book-agent_simple, item trap receiver

Figure 2.21 – Zabbix Latest data page for host lar-book-agent_simple, item trap receiver

There it is, our Zabbix trap in our Zabbix frontend.

How it works…

Now that we have built our new items, let's see how they work by diving into the theoretical side of Zabbix simple checks and trappers.

Simple checks

Zabbix simple checks are basically a list of built-in checks made for monitoring certain values. There is a list and description available on the Zabbix documentation wiki: https://www.zabbix.com/documentation/current/manual/config/items/itemtypes/simple_checks.

All of these checks are performed by the Zabbix server to collect data from a monitored host. For example, when we do the Zabbix simple check to check whether a port is open, our Zabbix server requests simply checks whether it can reach that port.

This means that if your monitored host's firewall is blocking port 22 from Zabbix server, we'll get a service is down value. However, this does not mean that SSH isn't running on the server itself:

Figure 2.22 – Zabbix server-to-host communication diagram

Figure 2.22 – Zabbix server-to-host communication diagram

Tip

Keep in mind that working with simple checks is dependent on external factors such as the firewall settings on the monitored host. When you build a custom simple check, make sure to check these factors as well.

Trappers

When working with Zabbix sender, we are doing exactly the opposite of most checks. We are building an item on our Zabbix server, which allows us to capture trap items. This allows us to build some custom checks to send data to our Zabbix server from a monitored host:

Figure 2.23 – Zabbix server trap receiver diagram

Figure 2.23 – Zabbix server trap receiver diagram

Let's say, for instance, that you want to build a custom Python script that, at the end of running the scripts, sends output to Zabbix server. We could ask Python to send this data with Zabbix sender, and suddenly you'd have this data available for processing on the Zabbix server.

We can really extend our options with Zabbix trapper and customize our Zabbix server even further.

You have been reading a chapter from
Zabbix 5 IT Infrastructure Monitoring Cookbook
Published in: Feb 2021
Publisher: Packt
ISBN-13: 9781800202238
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime