Page 1 of 1

Passive Service setup for Window Services

Posted: Wed Sep 06, 2023 1:43 pm
by Benco_NAdmin
Hello all,

I'm setting up passive monitors for some of my Windows servers services using NCPA. For the sake of my question, lets say I'm monitoring "Windows Audio" service (Audiosrv)

In the ncpa.cfg file, I've added the following command and am getting passive checks to my server

%HOSTNAME%| Windows Audio = services?service=Audiosrv&status=running

It comes up and I have a service being monitored. What I'd like to do is also have some performance graphing for this. Basically an auditable up/down like anything else you'd find in monitoring.

I did some digging and found you could add on to the command for Nagios to receive that will graph it:

label=value[UOM];warn;crit;min;max

Is there a way to format this so that I can have a "running" service as a 1 and a "stopped" service as a 0 so Nagios XI can do a performance graph? If not, what is the recommended way to easily audit times the service has stopped/started?

Thank you!

Re: Passive Service setup for Window Services

Posted: Fri Sep 08, 2023 3:21 pm
by bbahn
Hello,

If you're looking to get a custom return from NCPA, I would suggest creating a plugin such as the following powershell script:

Code: Select all

param (
    [Parameter(Mandatory=$true)]
    [string]$ServiceName
)

# Check the status of the specified service
$serviceStatus = Get-Service -Name $ServiceName | Select-Object -ExpandProperty Status

if ($serviceStatus -eq "Running") {
    Write-Output "OK - $ServiceName is running | service_status=1"
    exit 0
} else {
    Write-Output "CRITICAL - $ServiceName is not running | service_status=0"
    exit 2
}
and modifying your passive check into something like this:

Code: Select all

%HOSTNAME%|Windows Audio = plugins/check_srv.ps1 -ServiceName Audiosrv