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

Working with SNMP monitoring

Now let's do something I enjoy most when working with Zabbix: build SNMP monitoring. My professional roots lie in network engineering, and I have worked a lot with SNMP monitoring to monitor all these different network devices.

Getting ready

To get started, we need the two Linux hosts we used before in the previous recipes:

  • Our Zabbix server host
  • The host we used in the previous recipe to monitor via the Zabbix active agent

How to do it…

Monitoring via SNMP polling is easy and very powerful. We will start by configuring SNMPv3 on our monitored Linux host:

  1. Let's start by issuing the following commands to install SNMP on our host:

    For RHEL-based systems:

    dnf install net-snmp net-snmp-utils

    For Debian-based systems:

    apt-get install net-snmp net-snmp-utils
  2. Now let's create the new SNMPv3 user we will use to monitor our host. Please note that we'll be using insecure passwords, but make sure to use secure passwords for your production environments. Issue the following command:
    net-snmp-create-v3-user -ro -A my_authpass -X my_privpass -a SHA -x AES snmpv3user

    This will create an SNMPv3 user with the username snmpv3user, the authentication password my_authpass, and the privilege password my_privpass.

  3. Now restart the snmpd daemon and enable it at boot:
    systemctl restart snmpd.service
    systemctl enable snmpd.service

    This is all we need to do on the Linux host side; we can now go to the Zabbix frontend to configure our host. Go to Configuration | Hosts in your Zabbix frontend and click Create host in the top-right corner.

  4. Now fill in the host configuration page:
    Figure 2.11 – Zabbix host configuration page for host lar-book-agent_snmp

    Figure 2.11 – Zabbix host configuration page for host lar-book-agent_snmp

  5. Make sure to add the right out-of-the-box template as shown in the following screenshot:
    Figure 2.12 – Zabbix host template page for host lar-book-agent_snmp

    Figure 2.12 – Template OS Linux SNMP

    Tip

    While upgrading from an earlier Zabbix version to Zabbix 5, you won't get all the new out-of-the-box templates. If you feel like you are missing some templates, you can download them at the Zabbix Git repository: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates.

  6. We are using some macros in our configuration here for the username and password. We can use these macros to actually add a bunch of hosts with the same credentials. This is very useful, for instance, if you have a bunch of switches with the same SNMPv3 credentials.

    Let's fill in the macros under Administration | General and use the dropdown to select Macros. Fill in the macros like this:

    Figure 2.13 – Zabbix global macro page with SNMP macros

    Figure 2.13 – Zabbix global macro page with SNMP macros

    A cool new feature in Zabbix 5 is the ability to hide macros in the frontend; do keep in mind that these values are still unencrypted in the Zabbix database.

  7. Use the dropdown to change {$SNMPV3_AUTH} and {$SNMPv3_PRIV} to Secret text:
    Figure 2.14 – Zabbix secure text dropdown for SNMP auth and priv macros

    Figure 2.14 – Zabbix secure text dropdown for SNMP auth and priv macros

  8. Now after applying these changes, we should be able to monitor our Linux server via SNMPv3. Let's go to Monitoring | Hosts and check the Latest data page for our new host:
Figure 2.15 – SNMP latest data for host lar-book-agent_snmp

Figure 2.15 – SNMP latest data for host lar-book-agent_snmp

How it works…

When we create a host as we did in step 4, Zabbix polls the host using SNMP. Polling SNMP like this works with SNMP OIDs. For instance, when we poll the item called Free memory, we ask the SNMP agent running on our Linux host to show us the value for 1.3.6.1.4.1.2021.4.6.0. That value is then returned to us on the Zabbix server:

Figure 2.16 – Diagram showing communication between Zabbix server and SNMP host

Figure 2.16 – Diagram showing communication between Zabbix server and SNMP host

Of course, SNMPv3 adds authentication and encryption to this process.

SNMP OIDs work in a tree structure, meaning every number behind the dot can contain another value. For example, see this for our host:

1.3.6.1.4.1.2021.4 = UCD-SNMP-MIB::memory 

If we poll that Define acronym, we get several OIDs back:

.1.3.6.1.4.1.2021.4.1.0 = INTEGER: 0
.1.3.6.1.4.1.2021.4.2.0 = STRING: swap
.1.3.6.1.4.1.2021.4.3.0 = INTEGER: 1679356 kB
.1.3.6.1.4.1.2021.4.4.0 = INTEGER: 1674464 kB
.1.3.6.1.4.1.2021.4.5.0 = INTEGER: 1872872 kB
.1.3.6.1.4.1.2021.4.6.0 = INTEGER: 184068 kB

That includes our 1.3.6.1.4.1.2021.4.6.0 OID with the value that contains our free memory. This is how SNMP is built, like a tree.

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 R$50/month. Cancel anytime