Nagios Server Cluster report

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Post Reply
Posts: 13
Joined: Sat Feb 12, 2022 1:21 am

Nagios Server Cluster report

Post by SalinaSJames »

I am currently running Nagios Core 4.3.4 and looking for a way to run a reoccurring report to list per Pool the servers (IP address) within each pool. For instance..Default Pool 'PL_ASP_Citrix' (,, Default Pool 'PL_AAS_TA' (, IF I can report on the State of each (Active, Draining, or disable) all the better. My aim is to generate either JSON, csv or xml page.
Posts: 2
Joined: Thu Dec 29, 2022 3:21 am

Re: Nagios Server Cluster report

Post by SantinoBoyer »

Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article.
Posts: 1
Joined: Fri Apr 21, 2023 1:54 pm

Re: Nagios Server Cluster report

Post by bobbrencher01 »

The Nagios Server Cluster report provides comprehensive insights and analysis on the performance and health of the clustered Nagios servers, enabling efficient monitoring and management of network infrastructure for optimal reliability and uptime.
Posts: 1
Joined: Mon May 08, 2023 4:01 pm

Re: Nagios Server Cluster report

Post by LauraH »

To include the state of each server in the report (active, draining, or disabled), you can add the appropriate service checks to each server and include the service check results in the report. You can use the NagiosQL web interface to add service checks to each server and modify the report template to include the service check results.

Agile Onboarding[size]
Posts: 1
Joined: Tue May 09, 2023 10:56 pm

Re: Nagios Server Cluster report

Post by BillieDuncan »

Thank you so much for the post
Posts: 1
Joined: Mon May 22, 2023 12:35 pm

Re: Nagios Server Cluster report

Post by MercedesCole »

To generate a recurring report in Nagios Core 4.3.4 to list the servers within each pool, along with their IP addresses and state (Active, Draining, or Disabled), you can utilize Nagios Core's extensibility by writing a custom script or using an existing plugin. Here's an example approach using a custom script:

1. Create a script: Start by creating a script that retrieves the required information from Nagios Core and formats it into the desired output format (JSON, CSV, or XML). You can use your preferred scripting language (e.g., Bash, Python, Perl) to accomplish this. In this example, we'll use Python.

#!/usr/bin/env python3

import nagios
import json

# Nagios objects configuration file
nagios_cfg = '/path/to/nagios/etc/nagios.cfg'

# Parse Nagios configuration
cfg = nagios.cfg(nagios_cfg)

# List of pools
pools = []

# Loop through hosts
for host in cfg.hosts:
# Check if host belongs to a pool
if host.hostgroup_name.startswith('Default Pool'):
# Get pool name
pool_name = host.hostgroup_name.split(' ')[2]
# Get host IP address
ip_address = host.address
# Get host state
state = host.get_plugin_output().split('|')[0].strip()

# Append pool information
for pool in pools:
if pool['name'] == pool_name:
pool['servers'].append({'ip': ip_address, 'state': state})
pools.append({'name': pool_name, 'servers': [{'ip': ip_address, 'state': state}]})

# Generate output
output = json.dumps(pools, indent=4)

# Print output

Make sure to replace /path/to/nagios/etc/nagios.cfg with the actual path to your Nagios configuration file.

2.Save the script: Save the script on the Nagios Core server, for example, as, and make it executable (chmod +x

3.Test the script: Run the script manually to ensure it generates the desired output.

4. Schedule recurring report: Use a cron job to schedule the script execution at regular intervals. For example, to run the script every day at 9 AM, open the crontab file with the command crontab -e and add the following line:

0 9 * * * /path/to/ > /path/to/output.txt

Replace /path/to/ with the actual path to the script, and /path/to/output.txt with the desired path to save the report output.

Output format: If you prefer a CSV or XML output, you can modify the script accordingly or use existing libraries/modules for generating those formats in your chosen programming language.
This approach leverages Nagios' configuration file to retrieve the necessary information and generate the desired report. You can adapt the script to suit your specific requirements or use it as a starting point for further customization.
Post Reply