Learning NAGIOS 3.0
上QQ阅读APP看书,第一时间看更新

Chapter 4. Overview of Nagios Plugins

Nagios' strength comes from its ability to monitor servers and the services they offer in a large number of ways. What's more interesting is that all of these ways make sure that your services are provided as functional, are external plugins, and work in quite an easy way. Many of these are even shipped with Nagios, as we mentioned in Chapter 2, Installation and Configuration. Therefore, it is possible to either use existing plugins or write your own.

The previous chapter discussed basic configuration of host and service checking. Nagios can be set up to check if your services are up and running. This chapter describes how these checks work in more detail. It also introduces some of the Nagios plugins that are developed as a part of Nagios, and as a part of the Nagios Plugins project.

Nagios performs checks by running an external command, and uses the return code, along with output from the command, as information on whether the check worked or not. It is the command's responsibility to verify if a host or service is working at the time the command is invoked.

Nagios itself handles all of the internals, such as scheduling the commands to be run, storing their results, and determining what the status is for each host and service.

Nagios requires that all plugins follow a specific, easy-to-follow behavior in order for them to work smoothly. These rules are common for both host checks and service checks. It requires that each command returns specific result codes, which are:

Standard output from the command is not parsed in any way by Nagios. It is usually formatted in the following way:

PLUGIN STATUS - status description

Usually, the status description contains human-readable information that is visible using the web interface. Some sample outputs from various plugins and states are:

PING OK - Packet loss = 0%, RTA = 0.18 ms
DNS WARNING: 0.015 seconds response time
DISK CRITICAL - free space: /boot 18 MB (8% inode=99%)

Nagios plugins use options for their configuration. It is up to the plugin author's host to parse these options. However, most commands that come as part of the Nagios Plugins package use standard options and support the -h or --help options to provide a full description of all the arguments they accept.

Standard Nagios plugins usually accept the following parameters:

Commands that verify various daemons also have a common set of options. Many of the networking-related plugins use the following options in addition to the preceding standard ones

This chapter describes the commands provided by a standard distribution Nagios Plugins and is based on version 1.4.10. Before using specific options for a command, it is recommended that you use the --help option and familiarize yourself with the functionality available on your Nagios installation.

All plugins have their nonstandard options, described in more detail in this chapter. All commands described in this chapter also have a sample configuration for the Nagios check command. Even though some longer definitions might span multiple lines, please make sure that you put it on a single line in your configuration. Some of the plugins already have their command counterparts configured with the sample Nagios configuration that is installed along with Nagios. Therefore, it is also worth checking if your commands.cfg file contains a definition for a particular command.