Gear Up with Nagios Mod-Gearman: Maximize and Distribute Checks Efficiently

Picture of Shamas Demoret
Shamas Demoret
Technical Content Manager
Diagram of a Nagios XI server and two Nagios Mod-Gearman workers, with arrows showing traffic direction from XI on port 22 for worker deploy and sync, and inbound to the XI server on port 4730 for queue checking and result submission.

Nagios Mod-Gearman is a powerful open source Nagios Event Broker (NEB) module designed to help you get more checks from your Nagios server and achieve distributed monitoring in complex networks. With the release of Nagios XI 2024R2.1, it’s easier than ever to roll out and manage thanks to the new Remote Workers option in the user interface. In this article, we’ll explore this powerful tool, covering what it does, how it works, and how you can get it up and running.

What Nagios Mod-Gearman Does

Nagios Mod-Gearman (NMG) provides a way of offloading active check execution from the Nagios monitoring engine (in Nagios Core, Nagios XI, and Nagios CSP) to separate worker Linux servers. This capability provides a variety of benefits:

  • Load Reduction: Having another system execute check plugins can significantly reduce the load on your Nagios server, increasing the number of total checks possible.
  • Load Balancing: Multiple workers can be employed to more evenly distribute the check load.
  • Distributed Monitoring: Remote workers can be employed to check assets on remote network segments and forward the results upstream to your Nagios server.

By offloading the checks, you’ll be able to maximize the number of checks a single Nagios server can run and to check even remote networks and secured subnets that you don’t have inbound access to from your Nagios server.

How it Works

The two components of Nagios Mod-Gearman are NMG Server and NMG Worker:

NMG Server

The Server broker module lives on your Nagios server. It is configured either using the module.conf file in Nagios Core 4.5+ and Nagios XI versions between 2024R1.2 and 2024R2.0 or using the new Configuration Editor UI option, a brand-new Premium feature in Nagios XI 2024R2.1. The server module is used to define whether host, service, and specific hostgroup and servicegroup checks should be added to the queue for workers to fetch and execute. You can also define local hostgroups and servicegroups that will be ignored by NMG and handled by the Core engine.

Screenshot of the Nagios Mod Gearman Configuration Editor in the Nagios XI, used to configure the Gearman server broker module.
The NMG Configuration Editor in the Nagios XI UI.

NMG Worker

Although the Worker module can also run on your Nagios server itself, it is mainly designed to run on separate Linux servers. In Core 4.5+, XI versions between 2024R1.2 and 2024R2.0, and in situations where inbound access to the worker server from your Nagios XI server on Port 22 is not available, it is configured using the worker.conf file. In XI 2024R2.1+ workers can be configured using the Manage Workers UI option.

Each worker can be assigned to handle the general host and service queues, or specific hostgroups and servicegroups. By assigning only certain groups to your worker, you can achieve distributed monitoring even in complex networks.

Screenshot of the Manager Workers menu in the Nagios XI UI. This is used to configure, deploy, sync, and delete NMG workers.
Add, deploy, edit, sync, and delete NMG workers in the Nagios XI UI.

Plugins and Data Paths

An important note is that any plugins you wish a worker to execute need to be installed on the worker system. The Deploy function of Remote Workers will handle installation of the default plugins in Nagios XI, but custom plugins and their requirements will need to be manually added to any workers you want to handle checks that require them.

Worker communication with the NMG Server module is all inbound to your Nagios server from the workers on port 4730, so inbound access from Nagios to the workers is not necessary for Gearman itself to function. Workers reach out to Nagios both to check the queue to determine if there are checks they need to run and to forward back the results.

The Manage Worker function in the XI, which enables you to configure, deploy, and sync workers and settings right from the UI, requires inbound network access to the worker via SSH on Port 22.

This diagram outlines the direction of data flow in an NMG setup that includes both an inbound-accessible worker on the same network as Nagios and a worker running on a remote network:

Diagram of a Nagios XI server and two Nagios Mod Gearman workers (one local, one remote), with arrows showing traffic direction of inbound to worker from XI on port 22 for worker deploy and sync, and inbound to the XI server on port 4730 for queue checking and result submission.
NMG Workers can be both local and remote.

Initial Setup

If you’re using Nagios XI 2024R2.1+, NMG is pre-loaded and can be configured entirely in the web interface. Simply navigate to the Configure > Remote Workers menu. This guide covers all aspects of managing NMG from the XI UI, including an explanation of each Server and Worker setting:

Managing Nagios Mod-Gearman in the Nagios XI UI

If you’re using a Nagios XI version between 2024R1.2 and 2024R2.0, you can install and manage NMG from the command line.

In situations where inbound access to a worker is not possible, although you won’t be able to leverage the Manage Workers option in the XI interface, you can still manually install and leverage NMG workers. You’ll also still be able to centrally manage your NMG Server settings with the Configuration Editor. This document covers Server installation (p2) and Worker installation (p5) :

Integrating NMG with Nagios XI

Details on managing the Server module queue and Worker module settings from the command line via their text-based configuration files in various use cases can be found here:

Managing NMG Queues and Workers

If you’re using an older version of Nagios XI along with Mod Gearman, there is a path to using Nagios Mod Gearman. You’ll need to upgrade your XI install to at least 2024R1.2, then you can load Nagios Mod Gearman and migrate your configurations:

Migrating from Mod-Gearman to Nagios Mod-Gearman

Additional Resources

Compiling Nagios Mod-Gearman

Nagios Mod-Gearman Github

Project Page on nagios.org

Great Directions: Understand Architecture and Data Paths in Nagios Tools

Share: