You are previewing Mastering Zabbix - Second Edition.
O'Reilly logo
Mastering Zabbix - Second Edition

Book Description

Learn how to monitor your large IT environments using Zabbix with this one-stop, comprehensive guide to the Zabbix world

About This Book

  • Create a tailor-made monitoring solution based on your specific needs

  • Learn advanced techniques of Zabbix to monitor networks, performances, and other critical features in large environments

  • Integrate, customize, and extend your monitoring solutions with external components and software

  • Who This Book Is For

    This book is intended for system administrators and IT architects who need to better integrate their Zabbix installation with their surrounding environment. A basic, working knowledge of Zabbix and Linux is assumed so that the book can focus on how to use every component to its full advantage. It will also be helpful to be familiar with programming concepts and languages but if not, all the content in the book is thorough and well documented.

    What You Will Learn

  • Efficiently collect data from a large variety of monitoring objects

  • Organize your data in graphs, charts, maps, and slide shows

  • Build intelligent triggers and alarms to monitor your network proactively

  • Write your own custom probes and monitoring scripts to extend Zabbix

  • Configure Zabbix and its database to be high available and fault-tolerant

  • Automate repetitive procedures using Zabbix's API

  • Integrate Zabbix with external systems

  • Understand the protocol and how to interact with it by writing your own custom agent

  • In Detail

    Nowadays monitoring systems play a crucial role in any IT environment. They are extensively used to not only measure your system’s performance, but also to forecast capacity issues. This is where Zabbix, one of the most popular monitoring solutions for networks and applications, comes into the picture. With an efficient monitoring system in place you’ll be able to foresee when your infrastructure runs under capacity and react accordingly. Due to the critical role a monitoring system plays, it is fundamental to implement it in the best way from its initial setup. This avoids misleading, confusing, or, even worse, false alarms which can disrupt an efficient and healthy IT department.

    This new edition will provide you with all the knowledge you need to make strategic and practical decisions about the Zabbix monitoring system. The setup you’ll do with this book will fit your environment and monitoring needs like a glove. You will be guided through the initial steps of choosing the correct size and configuration for your system, to what to monitor and how to implement your own custom monitoring component. Exporting and integrating your data with other systems is also covered.

    By the end of this book, you will have a tailor-made and well configured monitoring system and will understand with absolute clarity how crucial it is to your IT environment.

    Style and approach

    This book is an easy to follow, step-by-step guide to monitoring network and performance in large environments with Zabbix. It is designed for real-world Zabbix administrators, and is comprised of a perfect mix of theoretical explanations and practical applications, making it your perfect companion.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the code file.

    Table of Contents

    1. Mastering Zabbix Second Edition
      1. Table of Contents
      2. Mastering Zabbix Second Edition
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. Preface
        1. What this book covers
        2. Who this book is for
        3. What you need for this book
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      9. 1. Deploying Zabbix
        1. Defining the environment size
        2. Zabbix architectures
          1. Installing Zabbix
            1. Prerequisites
          2. Setting up the server
            1. Setting up the agent
            2. Installing and creating the package
            3. Installing from packages
            4. Configuring the server
          3. Installing the database
          4. Some considerations about the database
          5. Sizing the database
          6. Some considerations about housekeeping
          7. The web interface
            1. The web wizard – frontend configuration
          8. Capacity planning with Zabbix
            1. The observer effect
            2. Deciding what to monitor
            3. Defining a baseline
            4. Load testing
            5. Forecasting the trends
        3. Summary
      10. 2. Distributed Monitoring
        1. Zabbix proxies
          1. Deploying a Zabbix proxy
            1. Zabbix's runtime proxy commands
            2. Deploying a Zabbix proxy using RPMs
            3. Considering a different Zabbix proxy database
          2. Understanding the Zabbix monitoring data flow
          3. Understanding the monitoring data flow with proxies
          4. Monitoring Zabbix proxies
        2. Security considerations
          1. No network configuration
          2. Network isolation
          3. Simple tunnels
            1. Secure Shell
            2. Stunnel
          4. A full-blown VPN
        3. Summary
      11. 3. High Availability and Failover
        1. Understanding high availability
        2. Understanding the levels of IT service
        3. Some considerations about high availability
          1. Automating switchover/failover with a resource manager
          2. Replicating the filesystem with DRBD
        4. Implementing high availability on a web server
          1. Configuring HTTPD HA
            1. Understanding Pacemaker and STONITH
            2. Pacemaker – is Quorum really needed?
            3. Pacemaker – the stickiness concept
            4. Pacemaker – configuring Apache/HTTPD
        5. Configuring the Zabbix server for high availability
        6. Implementing high availability for a database
          1. Clustering of PostgreSQL
          2. Mirrored logical volume with LVM and DRDB
            1. Prerequisite tasks to start with DRBD on LVM
            2. Creating a DRBD device on top of the LVM partition
            3. Enabling resources in DRBD
            4. Defining a primary device in DRDB
            5. Creating a filesystem on a DRBD device
          3. Pacemaker clusters – integrating DRBD
            1. Enabling the DRBD configuration
            2. Pacemaker – the LVM configuration
            3. Pacemaker – configuring PostgreSQL
            4. Pacemaker – the network configuration
            5. Pacemaker – the final configuration
            6. Cluster configuration – the final test
          4. DRBD performance and optimization
            1. DRBD efficient synchronization
            2. Enabling DRBD online verification
            3. DRBD – some networking considerations
        7. Summary
      12. 4. Collecting Data
        1. Gathering items as raw data
        2. Understanding the data flow for Zabbix items
          1. Understanding Zabbix trapper items
          2. The data flow overview
        3. Database monitoring with Zabbix
          1. Delving into ODBC
            1. Installing database drivers
            2. MySQL ODBC drivers
            3. PostgreSQL ODBC drivers
            4. Oracle ODBC drivers
            5. unixODBC configuration files
            6. Compiling Zabbix with ODBC
            7. Database monitor items
            8. Some considerations about the ODBC SQL query
        4. Zabbix JMX monitoring
          1. Considering JMX security aspects
          2. Installing a Zabbix Java gateway
          3. Configuring Zabbix JMX
            1. JMX keys in detail
            2. Issues and considerations about JMX
        5. Zabbix SNMP monitoring
          1. SNMP queries
          2. SNMP traps
            1. The snmptrapd process
            2. The perl trap handler
        6. Monitoring Zabbix SSH
          1. Configuring the SSH key authentication
        7. Monitoring Zabbix IPMI
          1. The first steps with IPMI
          2. Configuring IPMI accounts
          3. Configuring Zabbix IPMI items
        8. Monitoring the web page
          1. Authenticating web pages
          2. Logging out
        9. Aggregated and calculated items
          1. Aggregated items
          2. Calculated items
        10. Summary
      13. 5. Visualizing Data
        1. Graphs
          1. Analyzing simple graphs
          2. Analyzing ad hoc graphs
            1. Hacking ad hoc graphs
          3. Analyzing custom graphs
            1. Reviewing all the combinations of graph properties
        2. Visualizing the data through maps
          1. Creating your first Zabbix map
          2. Important considerations about macros and URLs
          3. Finally, inside the map
          4. Selecting elements
          5. Playing with macros inside maps
        3. Visualizing through screens
          1. Creating a screen
          2. Dynamic elements
        4. Visualizing the date through a slide show
        5. Controlling center slides and the big display challenge
          1. Considerations about slides on a big display
          2. Automated slide show
        6. IT services
          1. Configuring an IT service
        7. Summary
      14. 6. Managing Alerts
        1. Understanding trigger expressions
          1. Selecting items and functions
            1. Choosing between seconds and a number of measurements
            2. The date and time functions
            3. Trigger severity
            4. Choosing between absolute values and percentages
          2. Understanding operations as correlations
        2. Managing trigger dependencies
        3. Taking an action
          1. Defining an action
            1. The {EVENT.DATE} and {EVENT.TIME} macros
            2. The {INVENTORY.SERIALNO.A} and friends macros
          2. Defining the action conditions
          3. Choosing the action operations
            1. Steps and escalations
            2. Messages and media
            3. Remote commands
        4. Summary
      15. 7. Managing Templates
        1. Creating templates
        2. Adding entities to a template
          1. Using macros
            1. User-defined macros
        3. Importing and exporting templates
        4. Linking templates to hosts
          1. Nesting templates

          2. Combining templates
        5. Discovering hosts
        6. The active agent auto-registration
          1. Configuring the auto-registration
          2. The real-case scenario
        7. Low-level discovery
        8. Summary
      16. 8. Handling External Scripts
        1. External checks
          1. The script's placement
          2. Going deep into external checks
          3. Going inside the script
          4. General rules for writing scripts
            1. Considerations about external checks
        2. The user parameter
          1. The flexible user parameter
          2. Considerations about user parameters
        3. Sending data using zabbix_sender
          1. The new script
          2. Writing a wrapper script for check_ora_sendtrap
          3. The pros and cons of the dedicated script server
        4. Working with Zabbix protocols
          1. The Zabbix get protocol
          2. The Zabbix sender protocol
            1. An interesting undocumented feature
            2. Using the clock properties in JSON items
          3. The Zabbix agent protocol
            1. Some more possible responses
        5. The low-level discovery protocol
        6. Communicating with Zabbix
          1. Implementing the Zabbix_sender protocol in Java
          2. Implementing the Zabbix sender protocol in Python
          3. Some considerations about agent development
        7. Summary
      17. 9. Extending Zabbix
        1. Exploring the Zabbix API
          1. First steps through the API
          2. Authenticating through the API
          3. Using the PyZabbix library
        2. Exploring the Zabbix API with JQuery
        3. Mass operations
          1. Redistributing hosts to proxies
          2. Adding or updating users
        4. Exporting data
          1. Extracting tabular data
          2. Creating graphs from data
            1. The Graphviz suite of programs
            2. Creating a trigger dependency graph
          3. Generating Zabbix maps from dot files
        5. Summary
      18. 10. Integrating Zabbix
        1. Stepping into WhatsApp
          1. Getting ready to send messages
          2. Registering the yowsup client
          3. Sending the first WhatsApp message
          4. Securing the yowsup setup
          5. Creating our first Zabbix alert group
          6. Integrating yowsup with Zabbix
        2. An overview of Request Tracker
        3. Setting up RT to better integrate with Zabbix
          1. Creating a custom queue for Zabbix
          2. Customizing tickets – the links section
          3. Customizing tickets – ticket priority
          4. Customizing tickets – the custom fields
          5. Connecting to the Request Tracker API
        4. Setting up Zabbix to integrate with Request Tracker
        5. Creating RT tickets from the Zabbix events
        6. Summary
      19. Index