Nagios Core Administration Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

Introduction

Nagios Core is perhaps best thought of less as a monitoring tool and more as a monitoring framework. Its modular design allows any kind of program that returns appropriate values based on some kind of check as a check_command for a host or service, for use to ensure that a host or service is still responsive and functioning correctly. 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 is 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—returns 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 to permissions and owner restrictions, can be written in any language, can read variables from their environment, and can take parameters and options to modify how they work. Most importantly, they are entirely separate from Nagios Core itself (even if programmed by the same people) and the way in which they're used by the application can be changed.

To allow additional flexibility in how plugins are used, Nagios Core uses these programs according to the terms of a command definition. A command for a specific plugin defines the way in which that plugin is used, including its location in the filesystem, any parameters that should be passed to it, and any other options. In particular, parameters and options often include thresholds for the WARNING and CRITICAL states.

Nagios Core is usually downloaded and installed alongside a set of plugins called Nagios Plugins, which are available at https://nagios-plugins.org/, which this book assumes you have installed. These plugins were chosen because, as a set, they cover the most common needs for a monitoring infrastructure quite well. These common needs include checks for common services, such as web services, mail services, DNS services, and others. They also perform more generic checks, such as whether a TCP or UDP port is accessible and open on a server. It's possible that for most, if not all, of our monitoring needs, we won't need any other plugins. However, if we do need other plugins, Nagios Core makes it possible for us to use the existing plugins in novel ways using custom command definitions, to add third-party plugins written by contributors on the Nagios Exchange website, or even to write custom plugins ourselves from scratch in some special cases.