Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Nagios Core Administration Cookbook - Second Edition
Nagios Core Administration Cookbook - Second Edition
Nagios Core Administration Cookbook - Second Edition
Ebook951 pages6 hours

Nagios Core Administration Cookbook - Second Edition

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Over 90 hands-on recipes that will employ Nagios Core as the anchor of monitoring on your network

About This Book

- Master the advanced configuration techniques of Nagios Core to model your network better by improving hosts, services, and contacts
- Filter and improve the notifications that Nagios Core sends in response to failed checks, which can greatly assist you when diagnosing problems
- Pull Nagios Core's data into a database to write clever custom reports of your own devise

Who This Book Is For

If you are a network or system administrator and are looking for instructions and examples on working with Nagios Core, then this book is for you. Some basic shell command-line experience is required, and some knowledge of scripting would be helpful when we discuss how plugins work.

What You Will Learn

- Manage the configuration of Nagios Core with advanced techniques to achieve fine detail in your checks
- Find, install, and even write your own check plugins
- Filter notifications to send them to the right people or programs at the right time
- Work around difficult network accessibility issues and delegate checks to other machines
- Tweak a Nagios Core server to achieve both high performance and redundancy in case of disaster
- Process the results of checks performed by other machines to monitor backups and similar processes
- Extend Nagios Core to allow advanced scripting, reporting, and network visualization behavior

In Detail

Nagios Core is an open source monitoring framework suitable for any network that ensures both internal and customer-facing services are running correctly and manages notification and reporting behavior to diagnose and fix outages promptly. It allows very fine configuration of exactly when, where, what, and how to check network services to meet both the uptime goals of your network and systems team and the needs of your users.
This book shows system and network administrators how to use Nagios Core to its fullest as a monitoring framework for checks on any kind of network services, from the smallest home network to much larger production multi-site services. You will discover that Nagios Core is capable of doing much more than pinging a host or to see whether websites respond.
The recipes in this book will demonstrate how to leverage Nagios Core's advanced configuration, scripting hooks, reports, data retrieval, and extensibility to integrate it with your existing systems, and to make it the rock-solid center of your network monitoring world.

Style and approach

Each chapter contains a set of step-by-step recipes to perform an example of a commonly performed task related to network administration. The book begins by focusing closely on the properties and configuration of Nagios Core itself, and gradually moves on to other pieces of software that can support, manage, and extend the system.
LanguageEnglish
Release dateFeb 29, 2016
ISBN9781785883132
Nagios Core Administration Cookbook - Second Edition

Related to Nagios Core Administration Cookbook - Second Edition

Related ebooks

System Administration For You

View More

Related articles

Reviews for Nagios Core Administration Cookbook - Second Edition

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Nagios Core Administration Cookbook - Second Edition - Ryder Tom

    Table of Contents

    Nagios Core Administration Cookbook Second Edition

    Credits

    About the Author

    About the Reviewer

    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

    Sections

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Errata

    Piracy

    Questions

    1. Understanding Hosts, Services, and Contacts

    Introduction

    Creating a new network host

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new HTTP service

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new e-mail contact

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Verifying configuration

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new hostgroup

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new servicegroup

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new contactgroup

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new time period

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Running a service on all hosts on a group

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    2. Working with Commands and Plugins

    Introduction

    Finding a plugin

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Installing a plugin

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Removing a plugin

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating a new command

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Customizing an existing command

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using an alternative check command for hosts

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Writing a new plugin from scratch

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Implementing threshold checks in a plugin

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using macros as environment variables in a plugin

    Getting ready

    How to do it…

    How it works...

    There's more...

    See also

    3. Working with Checks and States

    Introduction

    Specifying how frequently to check a host or service

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Changing thresholds for PING RTT and packet loss

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Changing thresholds for disk usage

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Scheduling downtime for a host or service

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Managing brief outages with flapping

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Adjusting flapping percentage thresholds for a service

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    4. Configuring Notifications

    Introduction

    Configuring notification periods

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Configuring notifications for groups

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Choosing states for notification

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Specifying the number of failed checks before notification

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Automating contact rotation

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Defining an escalation for repeated notifications

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Defining a custom notification method

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Filtering notifications based on a host or service value

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    5. Monitoring Methods

    Introduction

    Monitoring PING for any host

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring SSH for any host

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Checking an alternative SSH port

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring mail services

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring web services

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Checking that a website returns a given string

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring database services

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring the output of an SNMP query

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring a RAID or other hardware device

    Getting ready

    How to do it...

    How it works...

    See also

    Creating an SNMP OID for monitoring

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    6. Enabling Remote Execution

    Introduction

    Monitoring local services on a remote machine with NRPE

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Setting the listening address for NRPE

    Getting ready

    How to do it...

    How it works...

    See also

    Setting allowed client hosts for NRPE

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Creating new NRPE command definitions securely

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Giving limited sudo(8) privileges to NRPE

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using check_by_ssh with key authentication instead of NRPE

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using check_mk instead of NRPE

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    7. Using the Web Interface

    Introduction

    Using the Tactical Overview

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    Viewing and interpreting availability reports

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    Viewing and interpreting trends

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    Viewing and interpreting notification history

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    Adding comments on hosts or services in the web interface

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    Viewing configuration in the web interface

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    Scheduling checks from the web interface

    Getting started

    How to do it...

    How it works...

    There's more

    See also

    Acknowledging a problem via the web interface

    Getting started

    How to do it...

    How it works...

    There's more...

    See also

    8. Managing Network Layout

    Introduction

    Creating a network host hierarchy

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Using the network map

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Choosing icons for hosts

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Establishing a host dependency

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Establishing a service dependency

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Monitoring individual nodes in a cluster

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Using the network map as an overlay

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    9. Managing Configuration

    Introduction

    Grouping configuration files in directories

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Keeping a configuration under version control

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Configuring host roles using groups

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Building groups using regular expressions

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Using inheritance to simplify configuration

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Defining macros in a resource file

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Using another object's directives in a host or service check

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Using custom directives

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Dynamically building host definitions

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    10. Security and Performance

    Introduction

    Using authentication for the Nagios Core web interface

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using authenticated contacts

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Writing debugging information to the Nagios log file

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Monitoring Nagios performance with nagiostats

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Setting up a redundant monitoring host

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    11. Automating and Extending Nagios Core

    Introduction

    Allowing and submitting passive checks

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Submitting passive checks from a remote host with NSCA

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Submitting passive checks in response to SNMP traps

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Setting up an event handler script

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Tracking host and service states with Nagiosgraph

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Reading status in a MySQL database with NDOUtils

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Reading status from a Unix socket with MK Livestatus

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Writing customized Nagios Core reports

    Getting ready

    How to do it...

    How it works...

    See also

    Getting extra visualizations with NagVis

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Writing custom Nagios Core management scripts

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Index

    Nagios Core Administration Cookbook Second Edition


    Nagios Core Administration Cookbook 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: January 2013

    Second Edition: February 2016

    Production reference: 1230215

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78588-933-2

    www.packtpub.com

    Credits

    Author

    Tom Ryder

    Reviewer

    John C. Kennedy

    Commissioning Editor

    Priya Singh

    Acquisition Editor

    Ruchita Bhansali

    Content Development Editor

    Mayur Pawanikar

    Technical Editor

    Vivek Pala

    Copy Editor

    Neha Vyas

    Project Coordinator

    Nidhi Joshi

    Proofreader

    Safis Editing

    Indexer

    Mariammal Chettiyar

    Graphics

    Disha Haria

    Production Coordinator

    Nilesh Mohite

    Cover Work

    Nilesh Mohite

    About the Author

    Tom Ryder is a systems administrator and former web developer from New Zealand. He uses Nagios Core as part of his day job as a systems administrator, monitoring the network for a regional Internet service provider. Tom works a great deal with Unix-like systems, being a particular fan of GNU/Linux, and writes about usage of open source, command-line development tools on his blog, Arabesque, at http://blog.sanctum.geek.nz.

    About the Reviewer

    John C. Kennedy has worked with Unix and Linux since 1998. He has worked on Nagios as a monitoring tool for much of the past 5 years.

    He has been reviewing and tech editing books in his spare time since 2001 and has about 20 open source-related books under his belt. He believes the best part of reviewing is that he learns something from every book he works on.

    John was born in the U.S. and grew up in Northern Virginia. He spent some time in the U.S. Air Force and has lived in Germany and the United Kingdom. He has been married to Michele since 1994 and has two children, Denise and Kieran. He currently lives in Virginia.

    I would like to thank my family, including my nephews, Aiden and Mason, and my niece, Harriet, for supporting all the silly things I do and for giving me time to work on this.

    Thanks also to Nidhi Joshi whose great patience and flexibility around my very hectic schedule were VERY much appreciated. Also, my thanks go to the author, Tom Ryder. I learned a lot from the book, and it has been one of my favorite books to work on. Everyone at Packt Publishing also deserves recognition for all their titles and the hard work that goes into producing every one of them.

    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 for more details.

    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

    Nagios Core, the open source version of the Nagios monitoring framework, is an industry standard for network monitoring hosted on Unix-like systems, such as GNU/Linux or BSD. It is very often used by network and system administrators to check the connectivity between hosts and to ensure that network services are running as expected.

    Where home-grown scripts performing network checks can rapidly become unmaintainable and difficult for newer administrators to customize safely, Nagios Core provides a rigorous and configurable monitoring framework to make checks in a consistent manner and to alert appropriate people and systems of any problem it detects.

    This makes Nagios Core a very general monitoring framework rather than an out-of-the-box monitoring solution, which is known to make it a little unfriendly to beginners and something of a black box, even to the otherwise experienced administrators. Busy administrators charged with setting up a Nagios Core system will often set it up to send PING requests to a set of hosts every few minutes and send them an e-mail about any problem, and otherwise never touch it. More adventurous administrators new to the system might instate a few HTTP checks to make sure that company websites respond.

    Nagios Core is capable of a great deal more than that, and this book's recipes are intended to highlight all of the different means of refining and controlling checks, notifications, and reporting for Nagios Core, rather than being a list of instructions for using specific plugins, of which there are many hundreds available online at the Nagios Exchange at https://exchange.nagios.org/. The book's fundamental aim is to get administrators excited about the possibilities of Nagios Core beyond elementary default checking behavior so that they can use much more of the framework's power and make it into the centerpiece of their network monitoring.

    This also includes installing and even writing custom plugins beyond the standard Nagios Plugins set, writing and refining one's own checks, working with the very powerful Simple Network Management Protocol (SNMP), and the recording and reporting of performance data. It also includes refining notification behavior to only send appropriate notifications at appropriate times to appropriate people or systems, basic visualization options, identifying breakages in network paths, clever uses of the default web interface, and even extending Nagios Core with other open source programs. It includes all this in order to virtually check any kind of host property or network service on any network.

    Where possible, this book focuses on add-ons written by the Nagios team themselves, particularly NRPE and NSCA. It omits discussion of popular forks of Nagios Core, such as Icinga. In the interest of conferring an in-depth understanding of advanced Nagios Core configuration, it also does not discuss any configuration frontends or wizards, such as NConf. Finally, as a Packt open source series book focusing on the use of the freely available Nagios Core, it also does not directly discuss the use of Nagios XI, the commercial version of the software supported by the Nagios team. This is done to instill a thorough understanding of Nagios Core itself, rather than to reflect the personal opinions of the author; curious administrators should definitely investigate all of these projects.

    What this book covers

    Chapter 1, Understanding Hosts, Services, and Contacts, gives you a basic idea of hosts, services, and contacts followed by the summary of this chapter.

    Chapter 2, Working with Commands and Plugins, explains the architecture of plugins and commands, including installing new plugins and defining custom uses of existing ones. It also walks us through how to write a new plugin with Perl.

    Chapter 3, Working with Checks and States, explains how Nagios Core performs its checks and how to customize that behavior, including scheduling downtime for hosts and services and managing flapping for hosts or services that keep going up and down.

    Chapter 4, Configuring Notifications, explains the logic of how Nagios Core decides on what basis to notify, when, and to whom, including examples of implementing a custom notification method, escalating notifications that aren't fixed after a certain period of time, and scheduling contact rotation.

    Chapter 5, Monitoring Methods, gives examples of the usage of some of the standard Nagios Plugins sets, moving from basic network connectivity checks with PING and HTTP to more complex and powerful checks involving SNMP usage.

    Chapter 6, Enabling Remote Execution, shows how to use NRPE as a means of working around the problem of not being able to check system properties directly over the network, including a demonstration of the more advanced methods of check_by_ssh and check_mk.

    Chapter 7, Using the Web Interface, shows some less-used features of the web interface to actually control how Nagios Core is behaving and to see advanced reports, rather than simply viewing the current state information. Use of the network map is not discussed here but in the next chapter.

    Chapter 8, Managing Network Layout, explains how to make Nagios Core aware of the structure and function of your network with a focus on hosts and services depending on one another to function correctly, including monitoring clusters and using that layout information to build a network status map, optionally with icons and a background.

    Chapter 9, Managing Configuration, shows how to streamline, refine, and control Nagios Core's configuration at a low level without the use of frontends. It focuses on the clever use of groups, templates, macros, and custom directives, and gives an example of generating configuration programmatically with the templating language m4.

    Chapter 10, Security and Performance, shows how to manage simple access control, debugg runtime problems, and keep tabs on how Nagios Core is performing, and also contains a demonstration of basic monitoring redundancy.

    Chapter 11, Automating and Extending Nagios Core, explains how to submit check results from other programs (including NSCA) to provide information about external processes via the commands file, and an introduction to a few popular add-ons (NDOUtils, MK Livestatus, NagVis, and Nagiosgraph).

    What you need for this book

    In an attempt to work with a standard installation of Nagios Core, this book's recipes assume that Nagios Core 4.0 or later and the Nagios Plugins set have been installed in /usr/local/nagios by the Nagios Quickstart Guides available at https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart.html.

    If your system's package repositories include a package for Nagios Core 4.0 or later that you would prefer to use, this should still be possible, but the paths of all the files are likely to be very different. This is known to be a particular issue with the nagios3 package on Debian or Ubuntu systems. If you are familiar with the differences in the installation layout that your packaging system imposes, then you should still be able to follow the recipes with only a few path changes.

    Who this book is for

    This book is aimed at system and network administrators who are comfortable with basic Unix-like system administration via the command line. It is best suited for GNU/Linux administrators, but should work fine for BSD administrators too. It has particular focus on the kind of administrator identified in the preface: one who is comfortable working with their Unix-like system, may well have a basic Nagios Core installation ready with some PING checks, and now wants to learn how to use more of the framework's power and understand its configuration in more depth.

    Administrators should be comfortable with installing library dependencies for the extensions, plugins, and add-ons discussed in the book. An effort is made to mention any dependencies; however, how these are best installed will depend on the system and its package repository. In almost all cases, this should amount to installing some common libraries and their headers from a packaging system. Debian and Ubuntu package names are given for some more complex cases.

    The easier recipes in the first five chapters involve some recap of the basics of configuring Nagios Core objects. Users completely new to Nagios Core who have just installed it will almost certainly want to start with Chapter 1, Understanding Hosts, Services, and Contacts, after completing the Nagios Quickstart Guide, as the latter chapters assume a fair amount of knowledge.

    Sections

    In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

    To give clear instructions on how to complete a recipe, we use these sections as follows:

    Getting ready

    This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

    How to do it…

    This section contains the steps required to follow the recipe.

    How it works…

    This section usually consists of a detailed explanation of what happened in the previous section.

    There's more…

    This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

    See also

    This section provides helpful links to other useful information for the recipe.

    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: Nagios Core will only need whatever information the ping(8) tool would need for its own check_ping command.

    A block of code is set as follows:

    define service {

        use                  generic-service

        host_name            sparta.example.net

        service_description  HTTP

        check_command        check_http

    }

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

    define host {

        host_name              sparta.example.net

        alias                  sparta

        address                192.0.2.21

        max_check_attempts    3

        check_period          24x7

        check_command          check-host-alive

        contacts              nagiosadmin

        notification_interval  60

     

        notification_period    24x7

    }

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

    # cd /usr/local/nagios/etc/objects # vi sparta.example.net.cfg

    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: If the server restarted successfully, the web interface should show a brand new host in the Hosts list, in the PENDING state as it waits to run a check that the host is alive.

    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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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 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. Understanding Hosts, Services, and Contacts

    In this chapter, we will cover the following recipes:

    Creating a new network host

    Creating a new HTTP service

    Creating a new e-mail contact

    Verifying configuration

    Creating a new hostgroup

    Creating a new servicegroup

    Creating a new contactgroup

    Creating a new time period

    Running a service on all hosts on a group

    Introduction

    Nagios Core is appropriate for monitoring services and states on all sorts of hosts and one of its primary advantages is that the configuration can be as simple or as complex as required. Many Nagios Core users will only ever use the software as a way to send PING requests to a few hosts on their local network, or possibly the Internet, and use it to send an administrator an e-mail or pager message if they don't get any replies. Nagios Core is vastly capable of monitoring more complex systems than this, scaling from simple LAN configurations to being the cornerstone for monitoring for an entire network operations team.

    However, for both simple and complex configurations of Nagios Core, the most basic building blocks of configuration are hosts, services, and contacts. These are the three things that administrators of even very simple networking setups will end up editing and probably creating. If you're a beginner to Nagios Core, you might have changed a hostname here and there or copied a stanza in a configuration to get it to do what you want; in this first chapter, we're going to look at what these configurations do in a bit more depth than that.

    In a Nagios Core configuration, hosts, services, and contacts are three fundamental types of objects:

    Hosts usually correspond to a computer, whether it's the machine running Nagios Core itself, a virtual machine hosted upon it, or a machine reachable via a network. Conceptually, however, a host can monitor any kind of network entity, such as the endpoint of a VPN.

    Services usually correspond to an arrangement for Nagios Core to check something about a host; this can either be something as simple as whether the monitoring server can get PING replies from the host or something more complicated as whether the value of an SNMP OID is within acceptable bounds.

    Contacts define a means to notify someone when events take place on the services on our hosts, such as not being able to get a PING response or send a test e-mail message.

    In this chapter, we'll add all three of these configurations, we'll learn how to group their definitions together to make the configuration more readable, and to work with hosts in groups rather than having to edit each one individually. We'll also set up a custom time period for notifications so that hardworking system administrators like us don't end up getting paged at midnight unnecessarily!

    Creating a new network host

    In this recipe, we'll start with the default Nagios Core configuration and

    Enjoying the preview?
    Page 1 of 1