Zabbix Network Monitoring - Second Edition
()
About this ebook
- Monitor your network and deploy impressive business solutions with Zabbix 3.0
- Manage hosts and system maintenance to keep your network performing for the people who use it
- A step-by-step guide to smarter network monitoring
This book is perfect for system admins who are new to Zabbix and who are interested in creating simple monitoring reports. This book assumes knowledge of basic system administration-related tasks.
Rihards Olups
Rihards Olups has over 10 years of experience in IT. He has had a chance to work with various systems, and most of that time has been spent with open source solutions. Exposure to Zabbix, one of the leading open source enterprise class monitoring solutions, was with the first public releases more than nine years ago, which has allowed to gain practical knowledge on the subject. Previously employed by a government agency, Rihards was mostly involved in open source software deployments ranging from server to desktop grade software, with a big emphasis on Zabbix. More recently the author has joined Zabbix SIA, the company behind the software that this book is about, which has allowed him to gain even more experience with the subject.
Related to Zabbix Network Monitoring - Second Edition
Related ebooks
Mastering Zabbix - Second Edition Rating: 0 out of 5 stars0 ratingsLearning Nagios 4 Rating: 5 out of 5 stars5/5Getting Started with Microsoft System Center Operations Manager Rating: 0 out of 5 stars0 ratingsFreeRADIUS Beginner's Guide Rating: 0 out of 5 stars0 ratingsSquid Proxy Server 3.1 Beginner's Guide Rating: 3 out of 5 stars3/5DevOps with Windows Server 2016 Rating: 0 out of 5 stars0 ratingsMastering Splunk Rating: 0 out of 5 stars0 ratingsNginx HTTP Server - Third Edition Rating: 0 out of 5 stars0 ratingsMastering Windows Server 2016 Rating: 0 out of 5 stars0 ratingsCacti 0.8 Beginner's Guide Rating: 0 out of 5 stars0 ratingsMastering Windows Server 2016 Rating: 5 out of 5 stars5/5Windows Performance Analysis Field Guide Rating: 4 out of 5 stars4/5Learning Nagios - Third Edition Rating: 0 out of 5 stars0 ratingsAdvanced Penetration Testing for Highly-Secured Environments - Second Edition Rating: 0 out of 5 stars0 ratingsMicrosoft Forefront UAG 2010 Administrator's Handbook Rating: 0 out of 5 stars0 ratingsZabbix Cookbook Rating: 0 out of 5 stars0 ratingsOpenFlow Cookbook Rating: 5 out of 5 stars5/5Zabbix Performance Tuning Rating: 5 out of 5 stars5/5Windows 2012 Server Network Security: Securing Your Windows Network Systems and Infrastructure Rating: 4 out of 5 stars4/5Learning RHEL Networking Rating: 0 out of 5 stars0 ratingsNetwork Automation A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsZabbix Network Monitoring Essentials Rating: 0 out of 5 stars0 ratingsCentOS 8 Essentials: Learn to Install, Administer and Deploy CentOS 8 Systems Rating: 0 out of 5 stars0 ratingsNetwork Storage: Tools and Technologies for Storing Your Company’s Data Rating: 0 out of 5 stars0 ratingsSolarWinds Orion Network Performance Monitor Rating: 0 out of 5 stars0 ratingsMastering Proxmox - Second Edition Rating: 0 out of 5 stars0 ratingsSELinux System Administration Rating: 0 out of 5 stars0 ratingsTroubleshooting OpenVPN Rating: 0 out of 5 stars0 ratingsWindows Server 2012 Unified Remote Access Planning and Deployment Rating: 0 out of 5 stars0 ratingsWindows Failover Clustering Design Handbook Rating: 0 out of 5 stars0 ratings
System Administration For You
CompTIA A+ Complete Review Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 5 out of 5 stars5/5Cybersecurity: The Beginner's Guide: A comprehensive guide to getting started in cybersecurity Rating: 5 out of 5 stars5/5Practical Data Analysis Rating: 4 out of 5 stars4/5Linux Commands By Example Rating: 5 out of 5 stars5/5PowerShell: A Comprehensive Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Learn SQL Server Administration in a Month of Lunches Rating: 0 out of 5 stars0 ratingsLearn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 0 out of 5 stars0 ratingsNetworking for System Administrators: IT Mastery, #5 Rating: 5 out of 5 stars5/5Learn PowerShell Scripting in a Month of Lunches Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Git Essentials Rating: 4 out of 5 stars4/5Learn Windows PowerShell in a Month of Lunches Rating: 0 out of 5 stars0 ratingsBash Command Line Pro Tips Rating: 5 out of 5 stars5/5Linux for Beginners: Linux Command Line, Linux Programming and Linux Operating System Rating: 4 out of 5 stars4/5Mastering Linux Shell Scripting Rating: 4 out of 5 stars4/5Mastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5The Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsDevOps Bootcamp Rating: 0 out of 5 stars0 ratingsLearn Cisco Network Administration in a Month of Lunches Rating: 0 out of 5 stars0 ratingsWordpress 2023 A Beginners Guide : Design Your Own Website With WordPress 2023 Rating: 0 out of 5 stars0 ratingsBash for Fun: Bash Programming: Principles and Examples Rating: 0 out of 5 stars0 ratingse-Discovery For Dummies Rating: 0 out of 5 stars0 ratingsBasics with Windows Powershell Rating: 0 out of 5 stars0 ratingsPractical Automation with PowerShell Rating: 0 out of 5 stars0 ratingsCloud Security For Dummies Rating: 0 out of 5 stars0 ratings
Reviews for Zabbix Network Monitoring - Second Edition
0 ratings0 reviews
Book preview
Zabbix Network Monitoring - Second Edition - Rihards Olups
Table of Contents
Zabbix Network Monitoring Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Zabbix
The first steps in monitoring
Zabbix features and architecture
Installation
Choosing the version and repository
Hardware requirements
Installing from the packages
RHEL/CentOS
EPEL
The Zabbix repository
OpenSUSE
Installing from source
The server and agent
Software requirements
Downloading the source
Compilation
Dash or underscore?
Initial configuration
Creating and populating the database
Starting up
Using systemd
Verifying the service's state
The web frontend
Prerequisites and setting up the environment
Using the web frontend configuration wizard
Step 1 – welcome
Step 2 – PHP prerequisites
Step 3 – database access
Step 4 – Zabbix server details
Step 5 – summary
Step 6 – writing the configuration file
Step 7 – finishing the wizard
Step 8 – logging in
Summary
2. Getting Your First Notification
Exploring the frontend
The user profile
Monitoring quickstart
Creating a host
Creating an item
Introducing simple graphs
Creating triggers
Configuring e-mail parameters
Creating an action
Information flow in Zabbix
Let's create some load
Basic item configuration
Monitoring categories
Availability
Performance
Security
Management
Efficiency
Item types
How items can be monitored
Using global search
Summary
3. Monitoring with Zabbix Agents and Basic Protocols
Using the Zabbix agent
Passive items
Cloning items
Manually querying items
Active items
An active agent with multiple servers
Supported items
Choosing between active and passive items
Item scheduling
Simple checks
Setting up ICMP checks
Tying it all together
Key parameter quoting
Positional parameters for item names
Using mass update
Value mapping
Units
Custom intervals
Flexible intervals
Custom scheduling
Copying items
Summary
4. Monitoring SNMP Devices
Using Net-SNMP
Using SNMPv3 with Net-SNMP
The engine ID
Authentication, encryption, and context
Adding new MIBs
Polling SNMP items in Zabbix
Translating SNMP OIDs
Dynamic indexes
SNMP bulk requests
Receiving SNMP traps
Using embedded Perl code
Filtering values by received data
Filtering values by originating host
Debugging
Handling the temporary file
SNMP Trap Translator
Using a custom script
Filtering the traps
Custom mapping
Database lookups
Summary
5. Managing Hosts, Users, and Permissions
Hosts and host groups
Host inventory
Editing inventory data manually
Populating inventory data automatically
Host maintenance
Creating maintenance periods
Collecting data during maintenance
Not collecting data during maintenance
Maintenance period options
One-time only maintenance
Daily maintenance
Weekly maintenance
Monthly maintenance
Ad-hoc maintenance
Users, user groups, and permissions
Authentication methods
Creating a user
Creating user groups
Permissions and maintenance
Summary
6. Detecting Problems with Triggers
Triggers
The trigger-and-item relationship
Trigger dependencies
Constructing trigger expressions
Preventing trigger flapping
Checking for missing data
Triggers that time out
Triggers with adaptable thresholds
Triggers with a limited period
Relative thresholds or time shift
Verifying system time
Human-readable constants
Customizing trigger display
Trigger severities
Trigger display options
Event details
Event generation and hysteresis
Summary
7. Acting upon Monitored Conditions
Actions
Limiting conditions when alerts are sent
Additional action conditions
Complex conditions
Dependencies and actions
Media limits for users
Sending out notifications
Using macros
Sending recovery messages
Escalating things
Runner analogy
Using scripts as media
Integration with issue management systems
Bugzilla
Computer Associates Unicenter Service Desk Manager
Atlassian JIRA
Remote commands
Global scripts
Configuring global scripts
Reusing global scripts in actions
Summary
8. Simplifying Complex Configurations with Templates
Identifying template candidates
Creating a template
Linking templates to hosts
Handling default templates
Changing the configuration in a template
Macro usage
User macros
Using multiple templates
Unlinking templates from hosts
Using mass update
Nested templates
Summary
9. Visualizing Data with Graphs and Maps
Visualize what?
Individual elements
Graphs
Simple graphs
Ad hoc graphs
Custom graphs
Working time and trigger line
Graph item function
Two y axes
Item sort order
Gradient line and other draw styles
Custom y axis scale
Percentile line
Stacked graphs
Pie graphs
Maps
Creating a map
Linking map elements
Selecting links
Routed and invisible links
Further map customization
Macros in labels
Link labels
Reflecting problems on map elements
Available map elements
Map filtering
Custom icons and background images
Icon mapping
Other global map options
Displaying host group elements
Numbers as icons
Sharing the maps
Summary
10. Visualizing Data with Screens and Slideshows
Screens
Dynamic screens
Additional screen elements
Templated screens
Slide shows
Showing data on a big display
Challenges
Non-interactive display
Information overload
Displaying a specific section automatically
Summary
11. Advanced Item Monitoring
Log file monitoring
Monitoring a single file
Filtering for specific strings
Monitoring rotated files
Alerting on log data
Extracting part of the line
Parsing timestamps
Viewing log data
Reusing data on the server
Calculated items
Quoting in calculated items
Referencing items from multiple hosts
Aggregate items
Aggregating across multiple groups
User parameters
Just getting it to work
Querying data that the Zabbix agent does not support
Flexible user parameters
Level of the details monitored
Environment trap
Things to remember about user parameters
Wrapper scripts
When not to use user parameters
External checks
Finding a certificate expiry time
Determining certificate validity
Sending in the data
Using an agent daemon configuration file
Sending values from a file
Sending timestamped values
SSH and Telnet items
SSH items
Telnet items
Custom modules
Summary
12. Automating Configuration
Low-level discovery
Network interface discovery
Automatically creating calculated items
Automatically creating triggers
Automatically creating graphs
Filtering discovery results
Filesystem discovery
Introducing the LLD JSON format
Including discovered graphs in screens
Custom thresholds with user macro context
CPU discovery
SNMP discovery
Creating custom LLD rules
Re-implementing CPU discovery
Discovering MySQL databases
Global regular expressions
Testing global regexps
Usage in the default templates
Network discovery
Configuring a discovery rule
Viewing the results
Reacting to the discovery results
Uniqueness criteria
Active agent autoregistration
Auto-registration metadata
Summary
13. Monitoring Web Pages
Monitoring a simple web page
Creating a web-monitoring scenario
Other scenarios and step properties
Alerting on web scenarios
Logging in to the Zabbix interface
Step 1: check the first page
Step 2: log in
Step 3: check login
Step 4: log out
Step 5: check logout
Authentication options
Using agent items
Getting the page
Checking page performance
Extracting content from web pages
Summary
14. Monitoring Windows
Installing the Zabbix agent for Windows
Querying performance counters
Using numeric references to performance counters
Using aliases for performance counters
Averaging performance counters over time
Querying WMI
Monitoring Windows services
Checking automatic services
Service discovery
Windows event log monitoring
Summary
15. High-Level Business Service Monitoring
Deciding on the service tree
Setting up IT services
Creating test items and triggers
Configuring IT services
Sending in the data
Viewing reports
Specifying uptime and downtime
Summary
16. Monitoring IPMI Devices
Getting an IPMI device
Preparing for IPMI monitoring
Setting up IPMI items
Creating an IPMI item
Monitoring discrete sensors
Using the bitwise trigger function
Summary
17. Monitoring Java Applications
Setting up the Zabbix Java gateway
Monitoring JMX items
Querying JMX items manually
What to monitor?
Summary
18. Monitoring VMware
Preparing for VMware monitoring
Automatic discovery
Available metrics
The underlying operation
VMware LLD configuration
Host prototypes
Summarizing default template interaction
Server operation and configuration details
Summary
19. Using Proxies to Monitor Remote Locations
Active proxy, passive proxy
Setting up an active proxy
Monitoring a host through a proxy
Proxy benefits
Proxy limitations
Proxy operation
Proxies and availability monitoring
Method 1 – Last access item
Method 2 – Internal proxy buffer item
Method 3 – Custom proxy buffer item
Setting up a passive proxy
Tweaking the proxy configuration
Summary
20. Encrypting Zabbix Traffic
Overview
Backend libraries
Pre-shared key encryption
Certificate-based encryption
Being our own authority
Setting up Zabbix with certificates
Concerns and further reading
Summary
21. Working Closely with Data
Getting raw data
Extracting from the frontend
Querying the database
Using data in a remote site
Diving further into the database
Managing users
Changing existing data
Finding out when
The when in computer language
Finding out what
Performing the change
Using XML import/export for configuration
Exporting the initial configuration
Modifying the configuration
The XML export format
Scripting around the export
Importing modified configuration
Generating hosts
Importing images
Starting with the Zabbix API
Simple operations
Obtaining the API version
Logging in
Enabling and disabling hosts
Creating a host
Deleting a host
Creating a value map
Obtaining history and trends
Issues with the Zabbix API
Using API libraries
Further reading
Summary
22. Zabbix Maintenance
Internal monitoring
New values per second
Zabbix server uptime
Cache usage
Internal process busy rate
Unsupported items and more problems
Counting unsupported items
Reviewing unsupported items
Internal events and unknown triggers
Backing things up
Backing up the database
Restoring from a backup
Separating configuration and data backups
Upgrading Zabbix
General version policy
Long-term support and short-term support
The upgrade process
Minor version upgrade
Upgrading binaries
Upgrading the frontend
Major-level upgrades
Database versioning
Gathering data during the upgrade
The frontend configuration file
Compatibility
Performance considerations
Who did that?
Exploring configuration file parameters
Zabbix agent daemon and common parameters
Zabbix server daemon parameters
Summary
A. Troubleshooting
Chapter introduction
Common issues
Installation
Compilation
Frontend
Backend
Locked out of the frontend
Monitoring
General monitoring
Monitoring with the Zabbix agent
User parameters
SNMP devices
IPMI monitoring
ICMP checks
Problems with simple checks
Problems with zabbix_sender and trapper items
General issues
Triggers
Actions
Discoveries and autoregistration
Troubleshooting Zabbix
The Zabbix log file format
Reloading the configuration cache
Controlling running daemons
Runtime process status
Further debugging
B. Being Part of the Community
Community and support
Chatting on IRC
Using the Zabbix wiki
Using the Zabbix forum
Filing issues on the tracker
Meeting in person
The Zabbix conference
Local communities
Following the development
Getting the source
Daily snapshots
Accessing the version control system
Looking at the changesets
Translating Zabbix
Commercial support options
Index
Zabbix Network Monitoring Second Edition
Zabbix Network Monitoring Second Edition
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2010
Second edition: August 2016
Production reference: 1030816
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-128-8
www.packtpub.com
Credits
Author
Rihards Olups
Reviewers
Werner Dijkerman
Volker Fröhlich
Adail Horst
Raymond Kuiper
Julien Recurt
Acquisition Editor
Sonali Vernekar
Content Development Editor
Samantha Gonsalves
Technical Editor
VIshal K. Mewada
Copy Editor
Madhusudan Uchil
Project Coordinator
Devanshi Doshi
Proofreader
Safis Editing
Indexer
Mariammal Chettiyar
Monica Ajmera Mehta
Graphics
Disha Haria
Production Coordinator
Nilesh Mohite
Cover Work
Nilesh Mohite
About the Author
Rihards Olups has over 15 years of experience in information technology, most of it with open source solutions. His foray into Zabbix, one of the leading open source enterprise-class monitoring solutions, was with the first public release back in 2001, which has allowed him to gain considerable knowledge on the subject. Previously employed by a government agency, Rihards was mostly involved in open source software deployment, ranging from server to desktop-grade software, with a big emphasis on Zabbix. Later, he joined Zabbix SIA, the company behind the software that this book is about, which allowed him to gain even more experience with the subject.
While at Zabbix, he helped Zabbix users and customers get the most value out of the monitoring tool and was responsible for delivering Zabbix training sessions that have been described by some participants as extremely practical and quite challenging.
He started working on the very first book on Zabbix, Zabbix 1.8 Network Monitoring, before joining Zabbix, and he finalized that book with even more in-depth details while helping advance Zabbix.
Rihards departed from Zabbix SIA and ended up seeing more of the user side again, including deployments of Zabbix in real-world environments.
Acknowledgments
I would like to thank my family and friends. Not spotlighting here—but if you think whether this includes you, yes, it does.
I would also like to thank all the people I have worked with. It was a great experience at the State Social Insurance Agency, and it was helped by being surrounded by nice people.
A huge thank you goes to everybody at Zabbix. Besides being experts in their own and many other fields, my Zabbix team members were extremely friendly, helpful, and welcoming. And it is true for everybody in the team. You are all great and will achieve a lot.
The Zabbix community deserves an extra mention. I have met a lot of wonderful people through the Zabbix community, and it is such a pleasure to meet them again every year in Riga, at the Zabbix conference. It is the community that takes Zabbix from the pure product level to something more.
And all you great people at Packt Publishing—thank you for dealing with the delays in Zabbix releases, my own schedule delays, and all the other small things. If you are reading this before the book is out, you know you have helped a lot.
Thank you all.
About the Reviewers
Werner Dijkerman is a systems engineer from the Netherlands. He has more than 10 years of experience in IT operations departments of different organizations. He started working with a leading online retailer in the Netherlands and continued in one of the leading software companies for general practitioners. He now works for iWelcome, the only established IDaaS provider in Europe.
With experience as a Windows and Linux admin, he also know his way around Java applications servers such as Tomcat and Jboss, (No)SQL databases, and monitoring systems. He started with Nagios in the early days and has even tried other tools such as Cacti, but Zabbix has been his main monitoring tool for several years now, with him finding ways and writing (Python) scripts to monitor everything it can.
He is also the author of the most popular Puppet module for Zabbix, wdijkerman-zabbix. It can be found at https://forge.puppetlabs.com/wdijkerman/zabbix on Puppet Forge. Besides this Puppet module, he has also created several Ansible roles under his alias dj-wasabi for four Zabbix components, which can be found on https://galaxy.ansible.com/detail#/role/7626.
Adail Horst is a free software evangelist, Zabbix translator, Zabbix documentation translator, and a lecturer on monitoring in various free software events (such as FISL, Latinoware, and Zabbix Conference). He has authored a book on the tool (De a Zabbix, in Portuguese), created Zabbix-Extras, and has experience in large IT environments monitored by Zabbix.
He is also one of the authors of the book A to Zabbix.
Raymond Kuiper is an IT infrastructure specialist with a strong focus on monitoring, networks, and operations. Raymond started using Zabbix 1.1.3 in 2006, when the company he was working for needed a flexible, integrated solution to monitor infrastructure availability and performance. Over the years, Raymond has become a keen supporter of Zabbix and has implemented monitoring with the tool for various organizations. He also likes to hang out on #zabbix on the Freenode IRC network to help out other Zabbix users.
Julien Recurt is an engineer who has multiples roles depending on the occasion. In the beginning, he worked for SUPINFO to enhance a complex and multisite infrastructure and reduce global costs. His big break was working with Ceph at Cloud-Solution, a French startup, to provide low-cost, scalable storage. Now, he works at Waycom, an Internet and web services provider, and manages about 1200 servers and virtual machines using Ansible.
I would like to thank everybody that contributes to open source software and also my coworkers who supported me in this job.
www.PacktPub.com
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
Imagine you're celebrating the start of the weekend with Friday-night drinks with a few friends. And then suddenly, your phone rings—one of the servers you administer has gone down, and it needs to be back up before tomorrow morning. So you drag yourself back to the office, only to discover that some logfiles have been growing more than usual over the past few weeks and have filled up the hard drive. While this scenario is very simplistic, something similar has happened to most IT workers at one or another point in their careers. To avoid such situations, this book will teach you to monitor your network's hardware, servers, and web performance using Zabbix, an open source system monitoring and reporting solution.
This book will guide you through setting up almost every feature in Zabbix. With step-by-step instructions, anybody should be able to configure monitoring. You could even say that this is an idiot's guide to Zabbix—but only because we all have had moments of not understanding something. In order to not leave you confused, throughout this book, I will try to hold your hand, push you forward, and explain everything in so much detail that you won't get frustrated at all.
What this book covers
Chapter 1, Getting Started with Zabbix, covers Zabbix installation from scratch, including the initial database, server and agent daemons, and web frontend, all running on the same machine. We will also configure the Zabbix web frontend, using PHP to access the database.
Chapter 2, Getting Your First Notification, covers configuring Zabbix using the frontend to set up data gathering, triggering upon specified conditions, and informing us by sending an e-mail for a single data source.
Chapter 3, Monitoring with Zabbix Agents and Basic Protocols, takes you through setting up the most widely used and basic data-gathering methods—Zabbix agents and simple checks, such as ICMP ping and direct TCP service checking.
Chapter 4, Monitoring SNMP Devices, teaches you how to set up the industry-standard monitoring protocol, SNMP. We will explore both polling by Zabbix and receiving SNMP traps, which will allow us to monitor a large variety of devices, including printers, switches, UPSes, and routers.
Chapter 5, Managing Hosts, Users, and Permissions, covers hosts, users, and permissions, including host and user group functionality and their impact on permissions. We will also explore related topics, including host and host group maintenance.
Chapter 6, Detecting Problems with Triggers, looks at ways to define which conditions are noteworthy by crafting expressions to detect values outside of the normal range, and other cases.
Chapter 7, Acting upon Monitored Conditions, helps you figure out how to react to triggers firing by sending an e-mail, launching an external script, opening a report in a separate bug tracker, or even restarting a faulty service. We will also learn to configure escalations in Zabbix and figure out how hysteresis works.
Chapter 8, Simplifying Complex Configuration with Templates, tells us how we did it all wrong before and teaches us to improve our configuration using templates that allow us to apply uniform configuration to a bunch of hosts while customizing thresholds per host with user macros. We'll also explore template nesting, which allows creating very flexible configuration in a large and mixed environment.
Chapter 9, Visualizing the Data with Graphs and Maps, explains how to create visual elements to display gathered data, including several types of graphs and interactive network maps.
Chapter 10, Visualizing the Data with Screens and Slideshows, helps you configure screens that collect various types of elements to display and slideshows that allow cycling through several screens in an automated fashion.
Chapter 11, Advanced Item Monitoring, explores more advanced ways to gather information using external, calculated, aggregate, and custom item types to retrieve any information.
Chapter 12, Automating Configuration, teaches us how to discover filesystems, network interfaces, and other entities on hosts with low-level discovery. On a higher level, we will explore the ability to automatically manage hosts via network discovery and active agent autoregistration.
Chapter 13, Monitoring Web Pages, takes us through monitoring the accessibility, performance, and availability of web pages using the built-in web scenario feature of Zabbix.
Chapter 14, Monitoring Windows, covers Windows monitoring by installing Zabbix agents, using performance counters, and retrieving data over WMI.
Chapter 15, High Level Business Service Monitoring, demonstrates the IT services
feature, which allows aligning monitored services in a tree and calculating SLA conformity. We will fake some data to see how this feature actually looks.
Chapter 16, Monitoring IPMI Devices, teaches us how to set up yet another industry-standard protocol, IPMI. Monitoring both analog and discrete IPMI sensors will be covered.
Chapter 17, Monitoring Java Applications, a separate daemon called Zabbix Java gateway is set up and used to retrieve basic information over JMX.
Chapter 18, Monitoring VMware, covers the built-in VMware monitoring support. We will explore the ability to automatically discover and monitor hypervisors and virtual machines.
Chapter 19, Using Proxies to Monitor Remote Locations, explores the usage of passive and active Zabbix proxies that collect the data on behalf of the Zabbix server and then transmit it back to the server, which helps with remote locations that can't be accessed directly because of firewall concerns and also reduces the load on the Zabbix server.
Chapter 20, Encrypting Zabbix Traffic, looks into one of the major new features in Zabbix 3.0: the ability to encrypt traffic between the Zabbix server, proxies, agents, and the get and sender utilities.
Chapter 21, Working Closely with Data, helps us figure out some details about how data is stored in the Zabbix database and how we can interact with it directly as well as using Zabbix's native XML import and export functionality to more easily create large amounts of configuration. We will also get started with the Zabbix API for more advanced automation needs.
Chapter 22, Zabbix Maintenance, teaches us about the Zabbix upgrade procedure, how different components of various versions can interact, and what database patching between versions involves. We will also explore the internal monitoring options available, discuss backup strategies, and talk in detail about all the configuration parameters Zabbix daemons have.
Appendix A, Troubleshooting, covers common pitfalls with installation, connectivity, configuration, and other areas.
Appendix B, Being Part of the Community, tells us how we are not alone and there's a community around the Zabbix monitoring solution, which we can reach via IRC, forums, and the community wiki.
What you need for this book
You will need at least one Linux system, which could be a virtual machine as well. Depending on specific features discussed, you might also benefit from the following:
Access to an SMTP (e-mail) server
More Linux systems
A device with SNMP support
A Windows system
A device with IPMI support
A Java virtual machine
A VMware instance
Some of these can be replicated on the same Linux box—for example, running snmpd or a Java VM will allow you to try out all the monitoring solutions without a separate system.
Who this book is for
This book is perfect for system admins who are new to Zabbix and are interested in creating simple monitoring reports. This book assumes knowledge of basic system administration tasks. Zabbix has added quite a lot of new features over the years, and many features new to 3.0 will be covered, so even experienced users of previous versions should be able to find new information.
Conventions
In this book, you will find a number of text styles 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, and user input are shown as follows: One of the first monitoring solutions most administrators implement is a simple shell script invoked from a crontab that checks some basic parameters such as disk usage or some service state, such as an Apache server.
A block of code is set as follows:
memory_limit = 128M
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
upload_max_filesize = 2M
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
memory_limit = 128M
post_max_size = 16M
max_execution_time = 300 max_input_time = 300
upload_max_filesize = 2M
Any command line input or output is written as follows:
# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: This screen doesn't offer us much to configure, so just click on Next step.
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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in 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 at 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 this book 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.
You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the SUPPORT tab at the top.
Click on Code Downloads & Errata.
Enter the name of the book in the Search box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on Code Download.
You can also download the code files by clicking on the Code Files button on the book's web page at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Zabbix-Network-Monitoring-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Downloading the color images of this book
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/ZabbixNetworkMonitoringSecondEdition_ColorImages.pdf.
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 could 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 to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy
Piracy of copyrighted 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 <copyright@packtpub.com> 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
If you have a problem with any aspect of this book, you can contact us at <questions@packtpub.com>, and we will do our best to address the problem.
Chapter 1. Getting Started with Zabbix
It's Friday night, and you are at a party outside the city with old friends. After a few beers, it looks as if this is going to be a great party, when suddenly your phone rings. A customer can't access some critical server that absolutely has to be available as soon as possible. You try to connect to the server using SSH, only to discover that the customer is right—it can't be accessed.
As driving after those few beers would quite likely lead to an inoperable server for quite some time, you get a taxi—expensive because of the distance (while many modern systems have out-of-band management cards installed that might have helped a bit in such a situation, our hypothetical administrator does not have one available). After arriving at the server room, you find out that some log files have been growing more than usual over the past few weeks and have filled up the hard drive.
While the preceding scenario is very simplistic, something similar has probably happened to most IT workers at one or another point in their careers. Most will have implemented a simple system monitoring and reporting solution soon after that.
We will learn how to set up and configure one such monitoring system—Zabbix. In this very first chapter, we will:
Decide which Zabbix version to use
Set up Zabbix either from packages or from the source
Configure the Zabbix frontend
The first steps in monitoring
Situations similar to the one just described are actually more common than desired. A system fault that had no symptoms visible before is relatively rare. A subsection of UNIX Administration Horror Stories (http://www-uxsup.csx.cam.ac.uk/misc/horror.txt) that only contains stories about faults that weren't noticed in time could probably be compiled easily.
As experience shows, problems tend to happen when we are least equipped to solve them. To work with them on our terms, we turn to a class of software commonly referred to as network monitoring software. Such software usually allows us to constantly monitor things happening in a computer network using one or more methods and notify the persons responsible, if a metric passes a defined threshold.
One of the first monitoring solutions most administrators implement is a simple shell script invoked from a crontab that checks some basic parameters such as disk usage or some service state, such as an Apache server. As the server and monitored-parameter count grows, a neat and clean script system starts to grow into a performance-hogging script hairball that costs more time in upkeep than it saves. While the do-it-yourself crowd claims that nobody needs dedicated software for most tasks (monitoring included), most administrators will disagree as soon as they have to add switches, UPSes, routers, IP cameras, and a myriad of other devices to the swarm of monitored objects.
So, what basic functionality can one expect from a monitoring solution? Let's take a look:
Data gathering: This is where everything starts. Usually, data is gathered using various methods, including Simple Network Management Protocol (SNMP), agents, and Intelligent Platform Management Interface (IPMI).
Alerting: Gathered data can be compared to thresholds and alerts sent out when required using different channels, such as e-mail or SMS.
Data storage: Once we have gathered the data, it doesn't make sense to throw it away, so we will often want to store it for later analysis.
Visualization: Humans are better at distinguishing visualized data than raw numbers, especially when there's a lot of data. As we have data already gathered and stored, it is easy to generate simple graphs from it.
Sounds simple? That's because it is. But then we start to want more features, such as easy and efficient configuration, escalations, and permission delegation. If we sit down and start listing the things we want to keep an eye out for, it may turn out that that area of interest extends beyond the network, for example, a hard drive that has Self-Monitoring, Analysis, and Reporting Technology (SMART) errors logged, an application that has too many threads, or a UPS that has one phase overloaded. It is much easier to manage the monitoring of all these different problem categories from a single configuration point.
In the quest for a manageable monitoring system, wondrous adventurers stumbled upon collections of scripts much like the way they themselves implemented obscure and not-so-obscure workstation-level software and heavy, expensive monitoring systems from big vendors.
Many went with a different category—free software. We will look at a free software monitoring solution, Zabbix.
Zabbix features and architecture
Zabbix provides many ways of monitoring different aspects of your IT infrastructure and, indeed, almost anything you might want to hook up to it. It can be characterized as a semi-distributed monitoring system with centralized management. While many installations have a single central system, it is possible to use distributed monitoring with proxies, and most installations will use Zabbix agents.
What features does Zabbix provide? Let's have a look:
A centralized, easy to use web interface
A server that runs on most UNIX-like operating systems, including Linux, AIX, FreeBSD, OpenBSD, and Solaris
Native agents for most UNIX-like operating systems and Microsoft Windows versions
The ability to directly monitor SNMP (SNMPv1, SNMPv2c, and SNMPv3) and IPMI devices
The ability to directly monitor Java applications using Java Management Extensions (JMX)
The ability to directly monitor vCenter or vSphere instances using the VMware API
Built-in graphing and other visualization capabilities
Notifications that allow easy integration with other systems
Flexible configuration, including templating
A lot of other features that would allow you to implement a sophisticated monitoring solution
If we look at a simplified network from the Zabbix perspective, placing the Zabbix server at the center, the communication of the various monitoring aspects matters. The following figure depicts a relatively simple Zabbix setup with several of the monitoring capabilities used and different device categories connected:
The Zabbix server directly monitors multiple devices, but a remote location is separated by a firewall, so it is easier to gather data through a Zabbix proxy. The Zabbix proxy and Zabbix agents, just like the server, are written in the C language.
Our central object is the Zabbix database, which supports several backends. The Zabbix server, written in the C language, and the Zabbix web frontend, written in PHP, can both reside on the same machine or on another server. When running each component on a separate machine, both the Zabbix server and the Zabbix web frontend need access to the Zabbix database, and the Zabbix web frontend needs access to the Zabbix server to display the server status and for some additional functionality. The required connection directions are depicted by arrows in the following figure:
While it is perfectly fine to run all three server components on a single machine, there might be good reasons to separate them, such as taking advantage of an existing high-performance database or web server.
In general, monitored devices have little control over what is monitored—most of the configuration is centralized. Such an approach seriously reduces the ability of a single misconfigured system to bring down the whole monitoring setup.
Installation
Alright, enough with the dry talk—what use is that? Let's look at the dashboard screen of the Zabbix web frontend, showing only a very basic configuration:
The Zabbix dashboard shows you a high-level overview of the overall status of the monitored system, the status of Zabbix, some of the most recent problems, and a few more things. This particular dashboard shows a very tiny Zabbix setup. Eventually, your Zabbix installation will grow and monitor different devices, including servers of various operating systems, different services and the hardware state on those servers, network devices, UPSes, web pages, other components of IT, and other infrastructure.
The frontend will provide various options for visualizing data, starting from lists of problems and simple graphs and ending with network maps and reports, while the backend will work hard to provide the information that this visualization is based on and send out alerts. All of this will require some configuration that we will learn to perform along the course of this book.
Before we can configure Zabbix, we need to install it. Usually, you'll have two choices—installing from packages or setting it up from the source code. Zabbix packages are available in quite a lot of Linux distribution repositories, and it is usually a safe choice to use those. Additionally, a Zabbix-specific repository is provided by SIA Zabbix (the company developing the product) for some distributions.
Tip
It is a good idea to check the latest installation instructions at https://www.zabbix.com/documentation/3.0/manual/installation.
Choosing the version and repository
At first, we will set up the Zabbix server, database, and frontend, all running on the same machine and using a MySQL database.
Should you use the packages or install from source? In most cases, installing from the packages will be easier. Here are a few considerations that might help you select the method:
There are certain benefits of using distribution packages. These include the following:
Automated installation and updating
Dependencies are usually sorted out
Compiling from source also has its share of benefits. They are as follows:
You get newer versions with more features and improvements
You have more fine-grained control over compiled-in functionality
But which version to choose? You might see several versions available in repositories, and those versions might not be equal. Since Zabbix 2.2, the concept of a Long-Term Support (LTS) release has been introduced. This determines how long support in the form of bug fixes will be available for. An LTS release is supported for 5 years, while a normal release is supported until a month after the release date of the next version. Zabbix 2.2 and 3.0 are LTS releases, while 2.4 and 3.2 are normal releases. Choose an LTS release for an installation that you don't plan to upgrade for a while and a normal release for something you intend to keep up to date. In this book, we will use Zabbix version 3.0.
Note
This policy might change. Verify the details on the Zabbix website: http://www.zabbix.com/life_cycle_and_release_policy.php.
The most widely used Zabbix architecture is a server that queries agents. This is what we will learn to set up initially so that we can monitor our test system.
As with most software, there are some prerequisites that we will need in order to run Zabbix components. These include requirements of hardware and other software that the Zabbix server and agent depend on. For the purpose of our installation, we will settle for running Zabbix on Linux, using a MySQL database. The specific Linux distribution does not matter much—it's best to choose the one you are most familiar with.
Hardware requirements
Hardware requirements vary wildly depending on the configuration. It is impossible to provide definite requirements, so any production installation should evaluate them individually. For our test environment, though, even as little RAM as 128 MB should be enough. CPU power in general won't play a huge role; Pentium II-class hardware should be perfectly capable of dealing with it, although generating graphs with many elements or other complex views could require more powerful hardware to operate at an acceptable speed. You can take these as a starting point as well when installing on a virtual machine.
Of course, the more resources you give to Zabbix, the snappier and happier it will be.
Installing from the packages
If you have decided to install Zabbix from the packages, package availability and the procedure will differ based on the distribution. A few distributions will be covered here—read the distribution-specific instructions for others.
RHEL/CentOS
RedHat Enterprise Linux or CentOS users have two repositories to choose from: the well-known Extra Packages for Enterprise Linux (EPEL) and the Zabbix repository. EPEL might be a safer choice, but it might not always have the latest version.
EPEL
If EPEL is not set up already, it must be added. For RHEL/CentOS 7, the command is similar to this:
# rpm -Uvh http://ftp.colocall.net/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
Tip
Check the latest available version at http://download.fedoraproject.org/pub/epel/7/x86_64/repoview/epel-release.html.
Once the repository has been set up, you may install the packages:
# yum install zabbix22-agent zabbix22-dbfiles-mysql zabbix22-server-mysql zabbix22-web-mysql
The Zabbix repository
First, the package that will define the Zabbix repository should be installed:
# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Once the repository has been set up, you may install the packages:
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
OpenSUSE
For OpenSUSE, Zabbix is available in the server:monitoring repository. First, the repository should be added and its package list downloaded (you might have to change the distribution version):
# zypper addrepo http://download.opensuse.org/repositories/server:monitoring/openSUSE_Leap_42.1/server:monitoring.repo # zypper refresh
Once the repository has been set up, you may install the packages:
# zypper install zabbix-server-mysql zabbix-agent zabbix-phpfrontend
Installing from source
If you have decided to install Zabbix from source, you will need to obtain the source, configure it, and compile it. After the daemons are put in place, the frontend will have to be set up manually as well.
The server and agent
At first, we will only set up the Zabbix server and agent, both running on the same system. We will set up additional components later during the course of this book.
Software requirements
Now, we should get to compiling the various components of Zabbix, so make sure to install the minimum required packages to get Zabbix working with MySQL. Here they are:
GCC
Automake
MySQL (http://www.mysql.com/)
Depending on your distribution and the desired functionality, you might also need some or all of the following packages:
zlib-devel
mysql-devel (for MySQL support)
glibc-devel
curl-devel (for web monitoring)
libidn-devel (curl-devel might depend on it)
openssl-devel (curl-devel might depend on it)
net-snmp-devel (for SNMP support)
popt-devel (net-snmp-devel might depend on it)
rpm-devel (net-snmp-devel might depend on it)
OpenIPMI-devel (for IPMI support)
libssh2-devel (for direct SSH checks)
libxm2-devel (for VMware monitoring)
unixODBC-devel (for database monitoring)
Java SDK (for Java gateway/JMX checks)
Downloading the source
There are several ways of downloading the source code of Zabbix. You can get it from a Subversion (SVN) repository, which will be discussed in Appendix A, Troubleshooting, however, for this installation procedure, I suggest you download version 3.0.0 from the Zabbix homepage, http://www.zabbix.com/. While it should be possible to use the latest stable version, using 3.0.0 will allow you to follow instructions more closely. Go to the Download section and grab the compressed source package. Usually, only the latest stable version is available on the download page, so you might have to browse the source archives, but do not take a development or beta version, which might be available.
To make further references easy, I suggested you choose a directory to work in, for example, ~/zabbix (~ being your home directory). Download the archive into this directory.
Compilation
Once the archive has finished downloading, open a terminal and extract it:
$ cd ~/zabbix; tar -zxvf zabbix-3.0.0.tar.gz
I suggest you install the prerequisites and compile Zabbix with external functionality right away so that you don't have to recompile as we progress.
For the purpose of this book, we will compile Zabbix with server, agent, MySQL, curl, SNMP, SSH, ODBC, XML (VMware), and IPMI support.
To continue, enter the following in the terminal:
$ cd zabbix-3.0.0 $ ./configure --enable-server --with-mysql --with-net-snmp --with-libcurl --with-openipmi --enable-agent --with-libxml2 --with-unixodbc --with-ssh2 --with-openssl
In the end, a summary of the compiled components will be printed. Verify that you have the following enabled:
Enable server: yes Server details: With database: MySQL WEB Monitoring: cURL SNMP: yes IPMI: yes SSH: yes TLS: OpenSSL ODBC: yes Enable agent: yes
If the configuration completes successfully, it's all good. If it fails, check the error messages printed in the console and verify that all prerequisites have been installed. A file named config.log might provide more detail about the errors. If you can't find out what's wrong, check Appendix A, Troubleshooting, which lists some common compilation problems.
To actually compile Zabbix, issue the following command:
$ make
You can grab a cup of tea, but don't expect to have much time—Zabbix compilation doesn't take too long; even an old 350-MHz Pentium II compiles it in approximately five minutes. On a modern machine, give it less than a minute. After the make process has finished, check the last lines for any error messages. If there are none, congratulations, you have successfully compiled Zabbix!
Now, we should install it. I suggest you create proper packages, but that will require some effort and will be distribution dependent. Another option is to run make install. This will place the files in the filesystem but will not register Zabbix as an installed package—removing and upgrading such software is harder.
If you have experience with creating distribution packages, do so—it is a better approach. If this is just a test installation, run the following:
# make install
Tip
Here and later in the book, a $ prompt will mean a normal user, while a # prompt will mean the root user. To run commands as root, su or sudo are commonly used.
But remember that test installations have the tendency of becoming production installations later—it might be a good idea to do things properly from the very beginning.
Dash or underscore?
Depending on the method of installation, you might get Zabbix binaries and configuration files using either a dash (minus) or an underscore, like this:
zabbix_server versus zabbix-server
zabbix_agentd versus zabbix-agentd
zabbix_server.conf versus zabbix-server.conf
While Zabbix itself uses an underscore, many distributions will replace it with a dash to follow their own guidelines. There is no functional difference; you just have to keep in mind the character that your installation uses. In this book, we will reference binaries and files using an underscore.
Initial configuration
After compilation, we have to configure some basic parameters for the server and agent. Default configuration files are provided with Zabbix. The location of these files will depend on the installation method you chose:
Source installation: /usr/local/etc
RHEL/CentOS/OpenSUSE package installation: /etc
On other distributions, the files might be located in a different directory. In this book, we will reference binaries and configuration files using relative names, except in situations where the absolute path is recommended or required.
To configure the Zabbix agent, we don't have to do anything. The default configuration will do just fine for now. That was easy, right?
For the server, we will need to make some changes. Open the zabbix_server.conf file in your favorite editor (you will need to edit it as the root user) and find the following entries in the file:
DBName
DBUser
DBPassword
DBName should be zabbix by default; we can leave it as is. DBUser is set to root, and we don't like that, so let's change it to zabbix. For DBPassword, choose any password. You won't have to remember it, so be creative.
Tip
In UNIX-like solutions, a hash character or # at the beginning of a line usually means that the line is commented out. Make sure not to start lines you want to have an effect with a hash.
Creating and populating the database
For the Zabbix server to store the data, we have to create a database. Start a MySQL client:
$ mysql -u root -p
Enter the root user's password for MySQL (you will have set this during the installation of MySQL, or the password could be something that is the default for your distribution). If you do not know the password, you can try omitting -p. This switch will tell the client to attempt to connect without a password (or with an empty password).
Tip
If you are using MySQL Community Edition from the packages and the version is 5.7.6 or higher, it generates a random password that is stored in logfiles. Check out the MySQL documentation at http://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html for more details.
Now, let's create the database. Add the user that Zabbix would connect to the database as, and grant the necessary permissions to this user:
mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.01 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'mycreativepassword'; Query OK, 0 rows affected (0.12 sec)
Use the password you set in the zabbix_server.conf file instead of mycreativepassword.
Quit the MySQL client by entering the following command:
mysql> quit
Let's populate the newly created database with a Zabbix schema and initial data. The following commands refer to the files as they appear in the Zabbix source. When installing from packages, these files could be located in a directory such as /usr/share/doc/zabbix-server-mysql-3.0.0/create/ or /usr/share/zabbix-server-mysql:
$ mysql -u zabbix -p zabbix < database/mysql/schema.sql $ mysql -u zabbix -p zabbix < database/mysql/images.sql $ mysql -u zabbix -p zabbix < database/mysql/data.sql
All three importing processes should complete without any messages. If there are any errors, review the messages, fix the issue, and retry the failed operation. If the import is interrupted in the middle of the process, you might have to clear the database—the easiest way to do this is to delete the database by typing this:
mysql> drop database zabbix; Query OK, 0 rows affected (0.00 sec)
Note
Be careful not to delete a database with important information! After deleting the Zabbix database, recreate it as we did before.
By now, we should have the Zabbix server and agent installed and ready to start.
Starting up
You should never start the Zabbix server or agent as root, which is common sense for most daemon processes. If you installed Zabbix from distribution packages, system users should have been created already—if not, let's create a new user to run these processes. You can use tools provided by your distribution or use the most widely available command—useradd, which we need to execute as root:
# useradd -m -s /bin/bash zabbix
Tip
For production systems, consider using different user accounts for the Zabbix server and agent. Otherwise, users with configuration rights will be able to discover Zabbix database credentials by instructing the agent to read the server configuration file. Some distribution packages, such as the EPEL and OpenSUSE ones, already use a separate user account called zabbixsrv or zabbixs by default.
This will create a user named zabbix with a home directory in the default location, /home/zabbix usually, and a shell at /bin/bash.
Tip
While using bash on a test system will make it easier to debug issues, consider using /bin/nologin or /bin/false on production systems.
If you installed from source, let's try the direct approach—running the binaries. The location of the binaries will depend on the chosen method of installation. Installing from the source without any extra parameters will place agent and server binaries in /usr/local/sbin; distribution packages are likely to place them in /usr/sbin. Assuming they are in your path, you can determine where the binaries are by running this:
# which zabbix_server
Tip
Keep in mind the potential use of a dash or minus instead of an underscore.
This will show something similar to the following:
/usr/sbin/zabbix_server
Alternatively, the whereis command can also list configuration and other related files:
# whereis zabbix_server
This would likely list the binary, the configuration file, and the manpage:
zabbix_server: /usr/sbin/zabbix_server /usr/local/etc/zabbix_server.conf /usr/share/man/man3/zabbix_server
Once you know the exact location of the binaries, execute the following as root user:
#
Tip
We are using zabbix_agentd, which runs as a daemon. Older versions also had the zabbix_agent executable, which provided an option to be run within internet service daemon (inetd); it did not support active items and, in most cases, had worse performance than the agent daemon.
This will start the Zabbix agent daemon, which should start up silently and daemonize. If the command produces errors, resolve them before proceeding. If it succeeds, continue by starting the Zabbix server:
#
Tip
Check the Zabbix server logfile, configurable in zabbix_server.conf. If there are database-related errors, fix them and restart the Zabbix server.
If you installed from the packages, execute this:
# service zabbix-agentd start Starting zabbix agent daemon done # service zabbix-server start Starting zabbix server daemon done
That should get the agent and server started. On OpenSUSE, you can also use a different, shorter syntax:
# rczabbix-agentd start # rczabbix-server start
Feel free to experiment with other parameters, such as stop and restart—it should be obvious what these two do.
You can verify whether services are running with the status parameter. For a service that is not running, you would get the following:
# service zabbix-server status Checking for service Zabbix server daemon unused
A running service would yield the following:
# service zabbix-agentd status Checking for service Zabbix agent daemon running
Tip
On some distributions, this might return more verbose output, including all of the running processes.
Some distributions might have another parameter called probe. This will check whether the corresponding service has been restarted since the last configuration file changes.
If it has been restarted, no output will be produced. If the service has not been restarted (thus possibly missing some configuration changes), the reload string will be output.
While it's nice to have Zabbix processes running, it's hardly a process one expects to do manually upon each system boot, so the server and agent should be added to your system's startup sequence. This is fairly distribution specific, so all possible variations can't be discussed here. With RHEL or CentOS, a command like this should help:
# chkconfig --level 345 zabbix-agent on # chkconfig --level 345 zabbix-server on
This will add both services to be started at runlevels 3, 4, and 5. For OpenSUSE, the following should work:
# chkconfig -s zabbix-server 35 # chkconfig -s zabbix-agentd 35
This will add both services to be started at runlevel 3 and runlevel 5, which are used for multiuser and networked environments. The previous commands might work on other distributions, too, although some distributions might use runlevel 4 instead of runlevel 5 for a graphical environment—consult your distribution's documentation when in doubt. There's usually no need to start Zabbix in single-user or non-networked runlevels (1 and 2), as data gathering requires network connectivity.
Tip
If installing from source, consider taking just the init scripts from the distribution packages.
With some init scripts in some distributions, it is even simpler than that:
# chkconfig -a zabbix_server zabbix_agentd
This will add both services as specified in the corresponding init scripts, which in our case should be runlevels 3 and 5, configured by the Default-Start parameter in the init script. If the command succeeds, you'll see the following output:
zabbix_server 0:off 1:off 2:off 3:on 4:off 5:on 6:off zabbix_agentd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
Using systemd
It is possible that your distribution uses the systemd boot manager to manage services. We won't dig into that much, but here's a quick, convenient lookup for the most common systemd alternatives to service-management commands:
Starting a service: systemctl start service_name
Stopping a service: systemctl stop service_name
Restarting a service: systemctl restart service_name
Enabling a service to start upon system startup: systemctl enable service_name
A nice summary can be found at https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet.
Verifying the service's state
While the init script method is a nice way to check a service's state for some distributions, it's not available everywhere and isn't always enough. Sometimes, you might want to use these other methods to check whether the Zabbix server or agent is running:
Checking running processes: The most common method to check whether a particular process is running is by looking at the running processes. You can verify whether the Zabbix agent daemon processes are actually running using this command:
$ ps -C zabbix_agentd
Output from the netstat command: Sometimes, an agent daemon might start up but fail to bind to the port, or the port might be used by some other process. You can verify whether some other process is listening on the Zabbix port or whether the Zabbix agent daemon is listening on the correct port by issuing this command:
$ netstat -ntpl
Process names won't be printed for other users' processes unless you are the root user. In the output, look for a line similar to this:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 19843/zabbix_agentd
This indicates that the zabbix_agentd process is running and listening on all addresses on port 10050, just what we need.
Telnetting to the port: Even when a service starts up and successfully binds to a port, there might be some connectivity issues, perhaps due to a local firewall. To quickly check connectivity on the desired port, you can try this:
$ telnet localhost 10050
This command should open a connection to the Zabbix agent daemon, and the daemon should not close the connection immediately. All of this applies to the Zabbix server as well, except that it uses a different port by default: 10051.
The web frontend
Now that we have the Zabbix server and agent either compiled and installed or installed from the distribution packages, and both daemons are running, you probably have a feeling that something's missing. We have only configured some low-level behavior, so where's the meat?
That's what the frontend is for. While, in theory, Zabbix can have multiple frontends, the only one with full functionality so far is the Zabbix web frontend, which is written in PHP. We have to set it up to configure Zabbix and get to those nice graphs everybody likes.