Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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

Setting up JMX monitoring

Built into Zabbix is JMX monitoring, so we can monitor our Java applications. In this recipe, we'll check out how to monitor Apache Tomcat with Zabbix JMX so we can get a feel for what this monitoring option is all about.

Getting ready

To get ready for this recipe, we are going to need our Zabbix server to monitor our JMX application.

I also used a CentOS 7 machine for this recipe, with Tomcat installed. It can be quite tricky to use Tomcat on CentOS 8 due to package dependencies, so I recommend sticking with 7 for now. You can add the following to your Tomcat configuration after installation to get it working in our recipe:

JAVA_OPTS="-Djava.rmi.server.hostname=10.16.16.155 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

How to do it…

To set up JMX monitoring, we are going to add a host to our Zabbix server that will monitor our Apache Tomcat installation. But first, we will need to add some settings to our /etc/zabbix/zabbix_server.conf file:

  1. Let's edit the zabbix_server.conf file by logging in to our Zabbix server and executing the following command:
    Vim /etc/zabbix/zabbix_server.conf
  2. We will then need to add the following lines to this file:
    JavaGateway=127.0.0.1
    StartJavaPollers=5
  3. We will also need to install the zabbix-java-gateway application on our Zabbix server with the following command:
    dnf install zabbix-java-gateway 
    systemctl start zabbix-java-gateway
    systemctl restart zabbix-server

    That is all we need to do on the server side of things to get JMX monitoring to work. Zabbix doesn't include these settings by default, so this is why we need to add the text to our file and install the application.

  4. To get started with monitoring our JMX host, go to Configuration | Hosts in your Zabbix frontend and click Create host in the top-right corner.

    We will then add a host with the following settings:

    Figure 2.36 – Zabbix item configuration page

    Figure 2.36 – Zabbix item configuration page

  5. Let's also make sure to add the following template to our host so we can actually start monitoring the JMX host:
    Figure 2.37 – Zabbix host template page

    Figure 2.37 – Zabbix host template page

  6. After this, our JMX icon should turn green; let's check this under Monitoring | Hosts. It should look like this:
    Figure 2.38 – Zabbix hosts page

    Figure 2.38 – Zabbix hosts page

  7. If we click on the Latest data for our new JMX monitored host, we should also see our incoming data. Check it out; it should return stats like these:
Figure 2.39 – Zabbix Latest data

Figure 2.39 – Zabbix Latest data

How it works…

Zabbix utilizes a Java gateway either hosted on Zabbix server itself or hosted on another server (proxy) to monitor JMX applications:

Figure 2.40 – Communication diagram between Zabbix server and Java

Figure 2.40 – Communication diagram between Zabbix server and Java

Zabbix polls the Java gateway and the Java gateway in turn communicates with our JMX application, as it does with Tomcat in our example. The data in turn is then returned through the same path and we can see our data in our Zabbix server.

See also

There are loads of applications that can be monitored through Zabbix JMX. Check out the Zabbix monitoring and integrations page for more uses of Zabbix JMX monitoring: https://www.zabbix.com/integrations/jmx.

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 $19.99/month. Cancel anytime
Banner background image