Defining commands

The commands that you may use for a given service need to be defined as well. The commands are defined within /etc/nagios-plugins/config, which is also included by /etc/nagios3/nagios.cfg.

This is a useful place to look if you want to see how an existing command is defined, or if you want to define your own custom command.

How to do it…

Let's create a custom command that uses an existing plugin to monitor a new service. Plex media servers are configured by default to use a web server configured on port 32400. So let's define a check_plex service that uses check_http on port 32400.

To do this, we're going to create /etc/nagios-plugins/config/plex.cfg:

define command{ command_name check_plex command_line /usr/lib/nagios/plugins/check_http ...

Get Linux Networking Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.