Skip to end of metadata
Go to start of metadata

Sub heading - How to use a Nagios plugin for service monitoring

Related Pages

Managing Servers and Services with NMIS8

Purpose

Nagios may have a plugin available that we'd like to leverage with NMIS.  NMIS is capable of integrating Nagios plugins.  This article will provide an example of how to do this to check the expiration date of an SSL certificate.

Steps

  • Determine which Nagios plugin to utilize
  • Find and Install the package containing the plugin
  • Test the plugin from the command line
  • Create NMIS services that utilize the Nagios plugin
  • Assign a Service to an NMIS node
  • Check the GUI

Determine Which Nagios Plugin to Utilize

Here are two pages that have have Nagios plugins.

https://www.monitoring-plugins.org/

http://nagios-plugins.org/

For this example we'll use the check_http plugin. 

Find and Install The Package that Contains the Plugin

Since the NMIS VM runs on CentOS we'll use Yum as an example.  For Debian based systems please see Appendix B for command examples.

In the example above we search the Yum repositorys for check_http and discover it is in the nagios-plugins-http.x86_64 package.  Next install it.

Very well, but where is the plugin?  We will need the full path to the plugin when we provision the NMIS service.

The installer has placed it in /usr/lib64/nagios/plugins.  Let's take a look at what else it has installed.

There were three other plugins in the package.  These are utility plugins that can invert a response or check if the response falls within a range.  To check how the check_http plugin works run it with the --help flag.  An example of this can be found in Appendix A of this article.  The help output states check_http should be run with the -C flag in order to check SSL certificate status.

-C <warn_age>[,<crit_age>]

With a command such as:

[root@opmantek ~]# /usr/lib64/nagios/plugins/check_http -I demo.opmantek.com -C 30, 15

If the certificate expiration date is greater than 30 days away it will return OK, warning will be returned if the expiration date is less than 30 days away, critical will be returned if the expiration date is less than 15 days away.

Test the Plugin From the Command Line

This is important because when we provision the NMIS service latter we need to have the correct syntax for the plugin.  In this example we use the plugin to check if the certificate is going to expire within the next 30 days.

Observe that the -C flag will check the certificates expiration date and provide a warning if it's less that 30 days away.

Create and Assign a Service to An NMIS Node

Create the Service

Via the top menu bar navigate to System -> System Configuration -> Services.  A new window 'Services' will render.  In the top right hand corner of this new window click 'add'.  A window such as the one below will appear.

Notice in the example above we have populated the Name, Service Type, Program Path, Program Args, and Collect Program Ouput fields. 

Assign Service To NMIS Node

Via the top menu bar navigate to System -> System Configuration > NMIS Nodes.  A new 'NMIS Nodes' window will render.  For this example we will assign the checkDemoCert to the node localhost.  Find the node localhost and click 'edit' on the right hand side.  A new window will render.  Find the Advanced Options Section.  Creatively using the shift and mouse left clicker, select the service checkdemocert, careful not to de-select any other provisioned servcies.

At the bottom of the window click the 'Edit and Update Node' button.  After some processing time a new window will render with debug detail of the update process.  Feel free to close this window.

Check the GUI

On the left side of the page find the 'Quick Search' box.  In the middle of this box enter 'localhost' in the 'Filter Device list by input string' field.  localhost should appear in the box below, click on it.  A new local host window will render.  using the top menu bar of this new window click on 'services'.  All the currently provisioned services will render.  On the left hand side click on the new service 'checkdemocert'.  A new window will render like the one below.

Notice it displays that the Certificate is OK because it will not expire within the next 30 days.  In the 'Last Status Text' field it displays the current expiration date.

Appendix A - check_http Documentation

Appendix B - Debian based systems - command line examples.

Finding the package that contains the subject plugin.

Installing the package.

Discovering the location of check_http.

  • No labels