Book Image

Mastering Zabbix (Second Edition)

Book Image

Mastering Zabbix (Second Edition)

Overview of this book

Table of Contents (18 chapters)
Mastering Zabbix Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Ever since its first public release in 2001, Zabbix has distinguished itself as a very powerful and effective monitoring solution. As an open source product, it's easy to obtain and deploy, and its unique approach to metrics and alarms has helped to set it apart from its competitors, both open and commercial. It's a powerful, compact package with very low requirements in terms of hardware and supporting software for a basic yet effective installation. If you add a relative ease of use, it's clear that it can be a very good contender for small environments with a tight budget. But it's when it comes to managing a huge number of monitored objects, with a complex configuration and dependencies, that Zabbix's scalability and inherently distributed architecture really shines. More than anything, Zabbix can be an ideal solution in large and complex distributed environments, where being able to manage efficiently and extract meaningful information from monitored objects and events is just as important if not more important than the usual considerations about costs, accessibility, and the ease of use.

This is a second edition book, the first having been coauthored by Andrea Dalle Vacche and Stefano Kewan Lee. The purpose of this book is to help you make the most of your Zabbix installation to leverage all of its power to monitor any large and complex environment effectively.

What this book covers

Chapter 1, Deploying Zabbix, focuses on choosing the optimal hardware and software configuration for the Zabbix server and database in relation to the current IT infrastructure, monitoring goals, and possible evolution. This chapter also includes a section that covers an interesting database-sizing digression, which is useful in calculating the final database size using a standard environment as the baseline. Correct environment sizing and a brief discussion about metrics and measurements that can also be used for capacity planning will be covered here. The chapter contains practical examples and calculations framed in a theoretical approach to give the reader the skills required to adapt the information to real-world deployments.

Chapter 2, Distributed Monitoring, explores various Zabbix components both on the server side and the agent side. Different distributed solutions will be given to the same example networks to highlight the advantages and possible drawbacks of each. In addition to the deployment and configuration of agents, the chapter takes proxies, maintenance, and change management into account too. This section will cover all the possible architectural implementations of Zabbix and add the pros and cons considerations.

Chapter 3, High Availability and Failover, covers the subjects of high availability and failover. For each of the three main Zabbix tiers, you will learn to choose among different HA options. The discussion will build on the information provided in the previous two chapters in order to end the first part of the book with a few complete deployment scenarios that will include high-availability servers and databases hierarchically organized in tiered, distributed architectures geared toward monitoring thousands of objects scattered in different geographical locations. This chapter will include a real-world, practical example and certain possible scenarios that have been implemented.

Chapter 4, Collecting Data, moves beyond simple agent items and SNMP queries to tackle a few complex data sources. The chapter will explore powerful Zabbix built-in functionalities, how to use them, and how to choose the best metrics to ensure thorough monitoring without overloading the system. There will also be special considerations about aggregated values and their use in monitoring complex environments with clusters or the more complex grid architectures.

Chapter 5, Visualizing Data, focuses on getting the most out of the data visualization features of Zabbix. This is quite a useful chapter, especially if you need to explain or chase a hardware expansion/improvement to the business unit. You will learn how to leverage live monitoring data to make dynamic maps and how to organize a collection of graphs for big-screen visualization in control centers and implement a general qualitative view. This chapter will cover the data center quality view slide show completely, which is really useful in highlighting problems and warning the first-level support in a proactive approach. The chapter will also explore some best practices concerning the IT services and SLA-reporting features of Zabbix.

Chapter 6, Managing Alerts, gives examples of complex triggers and trigger conditions as well as advice on choosing the right amount of trigger and alerting actions. The purpose is to help you walk the fine line between being blind to possible problems and being overwhelmed by false positives. You will also learn how to use actions to automatically fix simple problems, raise actions without the need for human intervention to correlate different triggers and events, and tie escalations to your operations management workflow. This section will make you aware of what can be automated, reducing your administrative workload and optimizing the administration process in a proactive way.

Chapter 7, Managing Templates, offers guidelines for effective template management: building complex template schemes out of simple components, understanding and managing the effects of template modification, maintaining existing monitored objects, and assigning templates to discovered hosts. This will conclude the second part of the book that is dedicated to the different Zabbix monitoring and data management options. The third and final part will discuss Zabbix's interaction with external products and all its powerful extensibility features.

Chapter 8, Handling External Scripts, helps you learn how to write scripts to monitor objects that are not covered by the core Zabbix features. The relative advantages and disadvantages of keeping the scripts on the server side or agent side, how to launch or schedule them, and a detailed analysis of the Zabbix agent protocol will also be covered. This chapter will make you aware of all the possible side effects, delays, and load caused by scripts; you will be able to implement all the needed external checks, as you will be well aware of all that is connected with them and the relative observer effect. The chapter will include different implementations of working with Bash, Java, and Python so that you can easily write your own scripts to extend and enhance Zabbix's monitoring possibilities.

Chapter 9, Extending Zabbix, delves into the Zabbix API and how to use it to build specialized frontends and complex extensions. It also covers how to harvest monitoring data for further elaboration and reporting. It will include simple example implementations written in Python that will illustrate how to export and further manipulate data, how to perform massive and complex operations on monitored objects, and finally, how to automate different management aspects such as user creation and configuration, trigger activation, and the like.

Chapter 10, Integrating Zabbix, wraps things up by discussing how to make other systems know about Zabbix and the other way around. This is key to the successful management of any large and complex environment. You will learn how to use built-in Zabbix features, API calls, or direct database queries to communicate with different upstream and downstream systems and applications. There will be concrete examples of possible interaction with inventory applications, trouble ticket systems, and data warehouse systems.

Who this book is for

As the book's title is Mastering Zabbix, Second Edition, you won't find any detailed, step-by-step tutorials (well, except the installation that will be covered from scratch, but with some useful tips) on the basic usage of Zabbix. Although you may find a lot of detailed information about installing the server or configuring items, triggers, and screens, you are expected to have at least a basic, working knowledge of how it all works so that you can focus on a more advanced approach for the same subjects. That said, it is possible to profit from the contents of this book even if you have no previous experience with Zabbix, but in that case, you are strongly encouraged to refer to the official Zabbix documentation that you can find at https://www.zabbix.com/documentation/2.4/manual to fill in any possible gaps in your knowledge.

What you need for this book

Before going deep into the Zabbix setup, it is important to know that the proposed setup covered here has been tested on a large-production environment (more than 1,800 hosts monitored, more than 89,500 monitored items, and more than 30,000 triggers) and that they can be considered valid for most large and very large environments. The high-availability solution proposed in this book has been widely tested, not purely as a disaster recovery exercise but during a real disaster (network cables were accidentally sheared by an excavating machine).

In this book, it is important to understand that most of the choices made have been on a practical basis and not driven by passion. One of the main choices made is using PostgreSQL as the official Zabbix RDBMS. We came across PostgreSQL as an RDBMS mostly for the mature and production ready features offered:

  • Hot backup is available by design

  • Atomicity, consistency, isolation, and durability—in short, it is fully ACID compliant

  • Many different, native standby configurations (hot standby, synchronous replication, and so on)

  • Efficient partitioning

Zabbix's database is a critical component, especially if you need to keep historical data available and guarantee constant performances day by day while the database is growing.

We have made some assumptions in this book: the packaging system used in our examples is yum, and then the distribution is obviously Red Hat Enterprise Linux. Anyway, excluding details such as package names and packet manager, the whole book is valid for all the Linux distributions. Furthermore, the proposed architectures and their implementations are not directly tied to a particular distribution. We did not use any Red Hat-specific clustering system or make any choice that you cannot reproduce on your favorite Linux distribution.

On reading this book, you will find different pieces of open source software, but out of all of them, it would be better if you are familiar with the following:

This book also focuses on system administrators who have some programming skills. We propose different workings for the implemented code snippet. With the proposed example, all well documented, you should be able to implement your own plugin or external software that is fully integrated with Zabbix. The code snippets proposed are in two different and widely diffused languages: Java and Python. These cover most of the current programmers' preferences and show, once you know how to implement the Zabbix protocol, how simple it is to switch between them.

Zabbix is more than a piece of monitoring software; it is an open source monitoring solution that can be explained as you want, and this book will make you aware of all the pros and cons of the possible solutions.

So, now it is time to go deep into Zabbix land!

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Most of these parameters are contained inside the php.ini file."

A block of code is set as follows:

zabbixsrv=zabbixsvr
[ -e /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf

start()
{
    echo -n $"Starting Zabbix server: "

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

; Maximum size of POST data that PHP will accept.
; http://www.php.net/manual/en/ini.core.php#ini.post-max-size
post_max_size = 16M

Any command-line input or output is written as follows:

# yum list postgres*

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Once we fill this form, we can click on Next."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.