Page 1 of 1

New to Nagios XI. Need to Check Service State

Posted: Tue Jan 14, 2025 10:08 am
by NacroGM
Hi guys - completely new to Nagios XI. We are just moving across from a much older version of Nagios where I was used to dealing with .cfg files for each host :D

We are slowly moving our machines into XI.

In the old version of Nagios we used NSClient++ (x64) installed on each host. We are now using the new NCPA agent.

We used to have a check_nrpe that checked the state of services. it was called CheckServiceState. It would basically alert us if any services that were set to Automatic were stopped. We were also able to exclude services from this check for each host.

We are looking to implement a similar check to all our Windows hosts in Nagios XI.
Can anyone offer any advice?

Really appreciate any help.

Re: New to Nagios XI. Need to Check Service State

Posted: Wed Jan 15, 2025 4:10 am
by Mikasa23
To monitor Windows service states in Nagios XI using the NCPA agent, configure the NCPA API on each host and ensure it is running properly. Define a check command in Nagios XI, such as querying the `services` endpoint with `check_ncpa.py`, to monitor services and alert if any set to Automatic are stopped. You can exclude specific services by tailoring the query arguments or using custom filters.
Chill Guy Clicker

Re: New to Nagios XI. Need to Check Service State

Posted: Thu Jan 16, 2025 4:24 am
by NacroGM
Thanks. So I would need to choose which services to monitor? I can't just have a blanket safety net check that checks ALL services?

With NSClient++ I do this to check running services:
command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c CheckServiceState -a CheckAll
This would monitor ALL services that were set to automatic, and let us know if one had stopped.

There doesn't appear to be an equivalent in NCPA check_ncpa_py.

Re: New to Nagios XI. Need to Check Service State

Posted: Thu Jan 16, 2025 6:31 pm
by bbahn
Hello @NacroGM,

You can check services with NCPA using the services API endpoint. To use check_ncpa.py (the recommended plugin for integrating Nagios XI with NCPA), you can do the following:
  • In a browser, navigate to your NCPA web server (https://your_ncpa_server_address:5693 by default).
  • Navigate to the API tab and select services
  • Customize your query to grab the particular services you want using regex, i.e.

    Code: Select all

    ^(?!cockpit|dracut|iscsi|initrd|sshd|systemd)
    to exclude services with cockpit, dracut, iscsi, ...etc. in their name
    Note: be careful to ensure your regex query here doesn't accidentally include/exclude services you didn't intend. I recommend using regex101.com and/or a neural network-based chatbot to aid in the construction of your regex queries.
  • Adjust any other query parameters as desired
    NCPA_query_building.jpg
  • Select Run as Nagios check as can be seen on the bottom left of this screenshot and grab the desired format depending on whether you want an active or passive check.
  • Configure your new check!
I haven't seen any documentation detailing this process, so I will go through our documentation in more detail and if I can't find anything, I'll create some documentation about how to do this.