Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Nagios Core Administration Cookbook
Nagios Core Administration Cookbook

Nagios Core Administration Cookbook: The ideal book for System Administrators who want to move their network monitoring to an advanced level. This book covers the powerful features and flexibility of Nagios Core, and its recipes can be applied to virtually any network.

eBook
$9.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Nagios Core Administration Cookbook

Chapter 2. Working with Commands and Plugins

In this chapter, we will cover the following recipes:

  • Finding a plugin

  • Installing a plugin

  • Removing a plugin

  • Customizing an existing command

  • Using an alternative check command for a host

  • Writing a new plugin from scratch

Introduction


Nagios Core is perhaps best thought of less as a monitoring tool, and more as a monitoring framework. Its modular design can use any kind of program which returns appropriate values based on some kind of check, such as a check_command plugin for a host or service. This is where the concepts of commands and plugins come into play.

For Nagios Core, a plugin is any program that can be used to gather information about a host or service. To ensure that a host was responding to PING requests, we'd use a plugin, such as check_ping, which when run against a hostname or address—whether by Nagios Core or not—would return a status code to whatever called it, based on whether a response was received to the PING request within a certain period of time. This status code and any accompanying message is what Nagios Core uses to establish what state a host or service is in.

Plugins are generally just like any other program on a Unix-like system; they can be run from the command line, are subject...

Finding a plugin


In this recipe, we'll follow a good procedure for finding a plugin appropriate to a specific monitoring task. We'll start by checking to see if an existing plugin is already available to do just what we need. If we can't find one, we'll check to see if we can use another more generic plugin to solve the problem. If we still find that nothing suits, we'll visit Nagios Exchange and search for an appropriate plugin there.

Getting ready

You should have a Nagios Core 3.0 or newer server running with a few hosts and services configured already, and you'll need to have a particular service on one of those hosts, which you're not sure how to monitor.

We'll use a simple problem as an example; we have a server named troy.naginet that runs an rsync process that listens on port 873. We're already monitoring the host's network connectivity via PING, but we'd like to have Nagios Core check whether the rsync server is available and listening at all times, in case it crashes while running...

Installing a plugin


In this recipe, we'll install a custom plugin that we retrieved from Nagios Exchange onto a Nagios Core server, so that we can use it as a Nagios Core command and hence check a service with it.

Getting ready

You should have a Nagios Core 3.0 or newer server running with a few hosts and services configured already, and have found an appropriate plugin to install, to solve some particular monitoring need. Your Nagios Core server should have internet connectivity to allow you to download the plugin directly from the website.

In this example we'll use check_rsync, which is available on the Web at http://exchange.nagios.org/directory/Plugins/Network-Protocols/Rsync/check_rsync/details.

This particular plugin is quite simple, consisting of a single Perl script with very basic dependencies. If you want to install this script as an example, then the server will also need to have a Perl interpreter installed; it's installed in /usr/bin/perl on many systems.

This example will also include...

Removing a plugin


In this recipe, we'll remove a plugin that we no longer need as part of our Nagios Core installation. Perhaps it's not working correctly, the service it monitors is no longer available, or there are security or licensing concerns with its usage.

Getting ready

You should have a Nagios Core 3.0 or newer server running with a few hosts and services configured already, and have a plugin that you would like to remove from the server. In this instance, we'll remove the now unneeded check_rsync plugin from our Nagios Core server.

How to do it...

We can remove a plugin from our Nagios Core instance as follows:

  1. Remove any part of the configuration that uses the plugin, including hosts or services that use it for check_command, and command definitions that refer to the program. As an example, the following definition for a command would no longer work after we removed the check_rsync plugin:

    define command {
        command_name  check_rsync
        command_line  $USER1$/check_rsync -H $HOSTADDRESS...

Creating a new command


In this recipe, we'll create a new command for a plugin that was just installed into the /usr/local/nagios/libexec directory on the Nagios Core server. This will define the way in which Nagios Core should use the plugin, and thereby allow it to be used as part of a service definition.

Getting ready

You should have a Nagios Core 3.0 or newer server running with a few hosts and services configured already, and have a plugin installed for which you'd like to define a new command. This will allow you to use it as part of a service definition. In this instance, we'll define a command for an installed check_rsync plugin.

How to do it...

We can define a new command in our configuration as follows:

  1. Change to the directory containing the objects configuration for Nagios Core. The default location is /usr/local/nagios/etc/objects:

    # cd /usr/local/nagios/etc/objects
    
  2. Edit the commands.cfg file:

    # vi commands.cfg
    
  3. At the bottom of the file, add the following command definition:

    define...

Customizing an existing command


In this recipe, we'll customize an existing command definition. There are a number of reasons why you might want to do this, but a common one is if a check is "overzealous", sending notifications for WARNING or CRITICAL states, which aren't actually terribly worrisome. It can also be useful if a check is too "forgiving" and doesn't detect actual problems with hosts or services.

Another reason is to account for peculiarities in your own network. For example, if you run HTTP daemons on a large number of hosts on the alternative port 8080 that you need to check, it would be convenient to have a check_http_altport command available. We can do this by copying and altering the definition for the vanilla check_http command.

Getting ready

You should have a Nagios Core 3.0 or newer server running with a few hosts and services configured already. You should also already be familiar with the relationship between services, commands, and plugins.

How to do it...

We can customize...

Using an alternative check command for hosts


In this recipe, we'll learn how to deal with a slightly tricky case in network monitoring—monitoring a server that doesn't respond to PING, but still provides some network service that requires checking.

It's good practice to allow PING where you can, as it's one of the stipulations in RFC 1122 and a very useful diagnostic tool not just for monitoring, but also for troubleshooting. However, sometimes servers that are accessed only by a few people might be configured not to respond to these messages, perhaps for reasons of secrecy. It's quite common for domestic routers to be configured this way.

Another very common reason for this problem, and the example we'll address here, is checking servers that are behind an IPv4 NAT firewall. It's not possible to address the host directly via an RFC1918 address, such as 192.168.1.20, from the public Internet. Pinging the public interface of the router therefore doesn't tell us whether the host for which it...

Writing a new plugin from scratch


Even given the very useful standard plugins in the Nagios Plugins set, and the large number of custom plugins available on Nagios Exchange, occasionally as our monitoring setup grows more refined, we may find that there is some service or property of a host that we would like to check, but for which there doesn't seem to be any suitable plugin available. Every network is different, and sometimes the plugins that others have generously donated their time to make for the community don't quite cover all your bases. Generally, the more specific your monitoring requirements get, the less likely it is that there's a plugin available that does exactly what you need.

In this example, we'll deal with a very particular problem that we'll assume can't be dealt with effectively by any known Nagios Core plugins, and we'll write one ourselves using Perl. Here's the example problem:

Our Linux security team wants to be able to automatically check whether any of our servers...

Left arrow icon Right arrow icon

Key benefits

  • Monitor almost anything in a network
  • Control notifications in your network by configuring Nagios Core
  • Get a handle on best practices and time-saving configuration methods for a leaner configuration
  • Use the web interface to control notification behaviour on the fly and for scheduled outages, without restarts
  • Pull Nagios Core's data into a database to write clever custom reports of your own devising

Description

Network monitoring requires significantly more than just pinging hosts. This cookbook will help you to comprehensively test your networks' major functions on a regular basis."Nagios Core Administration Cookbook" will show you how to use Nagios Core as a monitoring framework that understands the layers and subtleties of the network for intelligent monitoring and notification behaviour. Nagios Core Administration Guide introduces the reader to methods of extending Nagios Core into a network monitoring solution. The book begins by covering the basic structure of hosts, services, and contacts and then goes on to discuss advanced usage of checks and notifications, and configuring intelligent behaviour with network paths and dependencies. The cookbook emphasizes using Nagios Core as an extensible monitoring framework. By the end of the book, you will learn that Nagios Core is capable of doing much more than pinging a host or to check if websites respond.

Who is this book for?

This book is for System Administrators who are looking for recipes to help them deal with advanced network monitoring issues with Nagios Core.

What you will learn

  • Finding, installing, and writing your own plugins, and learning to reference them as Nagios Core commands for use as host and service checks, including workarounds for making checks through difficult network layouts such as those using Network Address Translation.
  • Managing notifications to send the right kind of notifications to the right people at the right time, and defining contact methods besides simple email messages, including an example of automatic contact rotation.
  • In-depth examples of using the standard set of Nagios Plugins for common network monitoring needs, with discussion of generic methods for monitoring the results of SNMP queries.
  • Remote monitoring methods to handle the situations where Nagios Core cannot directly check a service s status over the network, to check things such as database servers that only listen locally, or hardware devices with no SNMP OIDs exported.
  • Defining network structure and dependencies in Nagios Core to enable it to perform its notification behavior more intelligently, and allow you to very quickly find the "root" of particular problems; also how to reflect this structure in the network map once defined, and even decorate it.
  • Best practices for managing Nagios Core configuration to make it leaner, more robust, and better suited to programatically generating configuration as specified by other systems.
  • Automating other interactions with Nagios Core, including using passive checks to track tasks being performed both locally and in other parts of the network, or running scripts automatically in response to checks; also includes discussion of developing your own reports or vizualisations using automatically exported data from the system.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 25, 2013
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781849515573
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jan 25, 2013
Length: 366 pages
Edition : 1st
Language : English
ISBN-13 : 9781849515573
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 152.97
Nagios Core Administration Cookbook
$54.99
Puppet 3 Cookbook
$48.99
Learning Nagios 4
$48.99
Total $ 152.97 Stars icon
Banner background image

Table of Contents

11 Chapters
Understanding Hosts, Services, and Contacts Chevron down icon Chevron up icon
Working with Commands and Plugins Chevron down icon Chevron up icon
Working with Checks and States Chevron down icon Chevron up icon
Configuring Notifications Chevron down icon Chevron up icon
Monitoring Methods Chevron down icon Chevron up icon
Enabling Remote Execution Chevron down icon Chevron up icon
Using the Web Interface Chevron down icon Chevron up icon
Managing Network Layout Chevron down icon Chevron up icon
Managing Configuration Chevron down icon Chevron up icon
Security and Performance Chevron down icon Chevron up icon
Automating and Extending Nagios Core Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(9 Ratings)
5 star 77.8%
4 star 11.1%
3 star 0%
2 star 11.1%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Simon Nicoll Mar 23, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are a sysadmin and you want to set up a Nagios install fast but correctly so you don't have to re build it properly later then buy this, everything you need in is there... Simples!
Amazon Verified review Amazon
Andrew Feb 18, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers every corner of Nagios Core needed for a healthy setup. If this is your first time using Nagios Core, this is the book for you. Even if you have a working environment, this is a great resource to verify best practices are being followed - in terms of both security and usability.I recommend going through this book while configuring Nagios Core in a lab environment, especially if this is your first time. I was going through the recipes with a spare machine running Ubuntu Server 12.04 LTS.
Amazon Verified review Amazon
Richard J Breiten Apr 01, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have to say, most of my knowledge of Nagios comes solely from surfing the internet, trial and error, and Google. I wish I had this book over a year and a half ago when I first started learning about this software. The topics are extremely easy to follow and start from the very basics to advanced topics including redundant servers and monitoring Nagios own performance. The illustrations that accompany the text are very easy to follow and understand and help, rather than hinder, the information. I really like the way the book is laid in terms of chapters and sections - new information is presented, explained, and detailed, but then there's a section called "There's more..." which delves deeper into the specific topic. In all, for sys admins and others who wish they could monitor their networks in real-time and be more proactive, this book is an invaluable source and constant companion. I can't recommend this book enough. More information about this book can be found here - [...]. Do yourself a favor - save yourself the headaches, the constant Googling, and headscratching and pick up this book. You'll thank yourself in the end.
Amazon Verified review Amazon
Yeonki Feb 26, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've involved in a cloud development project. I use Nagios core for monitoring servers and devices in this project. As we know, Nagios is one of famous open sourced monitoring tools. I needed references in dealing with Nagios. While I was reading this, it remind me of basic concept of Nagios again.There are some sections in every chapter. "How to do it" , "How it works" and "There's more". it describes how we start a certain feature of Nagios according to the section in "How to do it" and then explains its mechanism with easy way in "How it works" and finally there is additional contents related to the chapter in "There's more"There is impressive paragraph in the book that nagios is close to MONITORING FRAMWORK rather than monitoring tool. It is perfect that describes nagios characteristic because it has already provide ecosystem, for example, lots of plugins support . And it is important to know where to find if need specific plugin that doesn't meet requirements. Author instructed that how to find a plugin that the administrator needs and where.People who are unfamiliar with Nagios, in my opinion, they may be confused that Nagios has SOFT and HARD state in response to server or host failing. In chapter 3, author tries to explain the difference between two by giving an understandable example.At last, in chapter 11, he gives an explanation about add-on projects like NRPE, NSClient++, NDOUtils and SNMP trap. If you need to extend the feature of Nagios to provide better-fitting solution on you own production, this will very helpful to you.
Amazon Verified review Amazon
A. Gage Mar 25, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is really well written and walks you through all aspects of Nagios from getting started to advanced topics such as configuring a redundant server. I have been using Nagios for many years and was surprised that I was able to expand my knowledge and develop a better understanding of topics I had previously struggled with. The author also does a great job explaining difficult concepts in a simple way that make it easy to understand. The format is a little odd, each of the topics are written as recipes of a cookbook of Nagios mastery. However, this actually seems to be a good way to dissect Nagios into small parts that are able to be easily understood. Each recipe also gives back and forward references to materials you might want to look at first as a prerequisite or afterwards to expand the concept. There are also lots of references to external content if you wish to learn more about specific topics that are covered briefly in the book. I recommend this book to anyone looking to get started with Nagios or to people who wish to expand their Nagios knowledge.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.