Forge Home

mcollective_agent_nrpe

Agent to query NRPE commands via Choria

34,273 downloads

3,838 latest version

3.1 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 4.2.0 (latest)
  • 4.1.0
  • 4.0.1
  • 4.0.0
  • 3.1.0
released Jan 7th 2022
This version is compatible with:
  • Puppet Enterprise 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
  • Puppet >= 6.0.0

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'choria-mcollective_agent_nrpe', '4.2.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add choria-mcollective_agent_nrpe
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install choria-mcollective_agent_nrpe --version 4.2.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

choria/mcollective_agent_nrpe — version 4.2.0 Jan 7th 2022

Choria NRPE Agent

This agent is capable of calling NRPE plugins on demand.

Background

Often after just doing a change on servers you want to just be sure that they’re all going to pass a certain nagios check.

Say you’ve deployed some new code and restarted tomcat, there might be a time while you will experience high loads, you can very quickly determine when all your machines are back to normal using this. It can take nagios many minutes to check all your machines which is a totally unneeded delay in your deployment process.

If you put your nagios checks on your servers using the common Nagios NRPE then this agent can be used to quickly check it across your entire estate.

I wrote a blog post on using this plugin to aggregate checks for Nagios: Aggregating Nagios Checks With MCollective

Setting up NRPE

This agent makes an assumption or two about how you set up NRPE, in your nrpe.cfg add the following:

include_dir=/etc/nagios/nrpe.d/

You should now set your commands up one file per check command, for example /etc/nagios/nrpe.d/check_load.cfg:

command[check_load]=/usr/lib64/nagios/plugins/check_load -w 1.5,1.5,1.5 -c 2,2,2

With this setup the agent will now be able to find your check_load command.

Actions

This agent provides the following actions, for details about each please run mco plugin doc agent/nrpe

  • runallcommands - Run all defined NRPE commands
  • runcommand - Run a NRPE command

Agent Installation

Add the agent and client:

mcollective::plugin_classes:
  - mcollective_agent_nrpe

Configuration

You can set the directory where the NRPE cfg files live, it defaults to /etc/nagios/nrpe.d:

mcollective_agent_nrpe::config:
 conf_dir: /usr/local/etc/nagios/nrpe.d

Alternatively if you have just one file with many plugins defined you can configure its location as below, this is is mutually exclusive with the previous settings:

mcollective_agent_nrpe::config:
 conf_file: /usr/local/etc/nagios/nrpe.cfg

And finally you can specify multiple directories as below:

mcollective_agent_nrpe::config:
 conf_path: /usr/local/etc/nagios/nrpe.d:/other/nrpe.d

Usage

Using generic mco rpc

You can use the normal mco rpc script to run the agent:

% mco rpc nrpe runcommand command=check_load
Discovering hosts using the mongo method .... 27

 * [ ============================================================> ] 27 / 27


dev1.example.com                             Request Aborted
   UNKNOWN
          Exit Code: 3
             Output: No such command: check_load
   Performance Data:


Summary of Exit Code:

           OK : 26
      UNKNOWN : 1
      WARNING : 0
     CRITICAL : 0


Finished processing 27 / 27 hosts in 380.57 ms

Supplied Client

Or we provide a client specifically for this agent that is a bit more appropriate for the purpose:

The client by default only shows problems:

% mco nrpe -W /dev_server/ check_load

 * [ ============================================================> ] 19 / 19

dev1.example.com                           status=UNKNOWN
    No such command: check_load

Summary of Exit Code:

           OK : 18
      UNKNOWN : 1
      WARNING : 0
     CRITICAL : 0


Finished processing 19 / 19 hosts in 216.59 ms

To see all the statusses:

% mco nrpe -W /dev_server/ check_load -v
Discovering hosts using the mongo method .... 3

 * [ ============================================================> ] 6 / 6

dev1.example.com                           status=UNKNOWN
    No such command: check_load

dev9.example.com                           status=OK
    OK - load average: 0.00, 0.00, 0.00

dev7.example.com                           status=OK
    OK - load average: 0.00, 0.00, 0.00

Summary of Exit Code:

           OK : 2
      UNKNOWN : 1
     CRITICAL : 0
      WARNING : 0


---- check_load NRPE results ----
           Nodes: 3 / 3
     Pass / Fail: 2 / 1
      Start Time: Fri Dec 14 11:21:58 +0000 2012
  Discovery Time: 50.86ms
      Agent Time: 212.90ms
      Total Time: 263.76ms

Data Plugin

The NRPE Agent ships with a data plugin that will enable you to filter discovery on the results of NRPE commands.

%  mco rpc rpcutil ping -S "Nrpe('check_disk1').exitcode=0"
Discovering hosts using the mc method for 3 second(s) .... 1

 * [ ============================================================> ] 1 / 1


dev2.example.com
   Timestamp: 1355484245


Finished processing 1 / 1 hosts in 138.15 ms