Chapter 6.  Using the Nagios Plugins

The previous chapters discussed the basic configuration of host and service checking along with the description of the web interface. 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.

The strength of Nagios comes from its ability to monitor servers and 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, Installing Nagios 4, and Chapter 3, Configuring Nagios. Therefore, it is possible to either use the existing plugins or write your own.

In this chapter, you will learn the checks that can be made using the Nagios Plugins project, and we will cover the following items:

  • Understanding how checks work
  • Monitoring using the standard network plugins
  • Monitoring the e-mail servers
  • Monitoring network services
  • Monitoring the database systems
  • Monitoring the storage space
  • Monitoring the resources
  • Monitoring other operations
  • Additional and third-party plugins

Understanding checks in Nagios

Nagios is a monitoring tool. It 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.

It is required that all plugins follow a specific behavior in order for them to work smoothly. These rules are common for both host and service checks. It requires that each command returns specific result codes, which are outlined in the following table:

Exit code

Status

Description

0

OK

Working correctly

1

WARNING

Working, but needs attention (for example, low resources)

2

CRITICAL

Not working correctly or requires attention

3

UNKNOWN

Plugin was unable to determine the status for the host or service

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 as follows:

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 command-line switches to provide a full description of all the arguments they accept.

Standard Nagios plugins usually accept the following parameters:

Option

Description

-h, --help

Provide help

-V, --version

Print the exact version of the plugin

-v, --verbose

Make the plugin report more detailed information on what it is doing

-t, --timeout

Timeout (seconds); after this time, plugin will report the CRITICAL status

-w, --warning

Plugin-specific limits for the WARNING status

-c, --critical

Plugin-specific limits for the CRITICAL status

-H, --hostname

Host name, IP address, or Unix socket to communicate with

-4, --use-ipv4

Use IPv4 for network connectivity

-6, --use-ipv6

Use IPv6 for network connectivity

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:

Option

Description

-p, --port

TCP or UDP port to connect to

-w, --warning

Response time that will issue a WARNING status (seconds)

-c, --critical

Response time that will issue a CRITICAL status (seconds)

-s, --send

String that will be sent to the server

-e, --expect

String that should be sent back from the server (option might be passed several times; refer to --all for details)

-q, --quit

String to send to the server to close the connection

-A, --all

In case multiple --expect parameters are passed, this option indicates that all responses need to be received; if this option is not present, at least one matching result indicates a success

-m, --maxbytes

The maximum number of bytes to read when expecting a string to be sent back from the server; after this number of bytes, a mismatch is assumed

-d, --delay

Delay in seconds between sending a string to server and expecting a response

-r, --refuse

Status that should be indicated in case the connection is refused (ok, warn, crit; defaults to crit)

-M

Status in case the expected answer is not returned by the server (ok, warn, crit; defaults to warn)

-j, --jail

Do not return output from the server in plugin output text

-D, --certificate

The number of days that the SSL certificate must still be valid; requires -ssl

-S, --ssl

Connect using SSL encryption

-E, --escape

Allows using , , or \ in send or quit string; must be passed before --send or --quit option

Note

Please note that the option names are case sensitive. For many plugins, there are options that have their abbreviated name the same, but with different cases. For example, both -e and -E as well as -m and -M are valid options for most of the plugins. It is important to distinguish the lower case and upper case options.

All the commands support the --verbose option (or -v for short variant of it) that will print out useful information about the test. It is recommended that you add the -v option whenever you run into issues with getting a plugin to work.

This chapter describes the commands provided by a standard distribution Nagios Plugins and is based on version 2.1.1. 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 non-standard options and are 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, 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.144.32