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!
Passive Service setup for Window Services
-
- Posts: 3
- Joined: Thu Jan 27, 2022 9:41 am
-
- Posts: 318
- Joined: Thu Jan 12, 2023 5:42 pm
Re: Passive Service setup for Window Services
Hello,
If you're looking to get a custom return from NCPA, I would suggest creating a plugin such as the following powershell script:
and modifying your passive check into something like this:
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
}
Code: Select all
%HOSTNAME%|Windows Audio = plugins/check_srv.ps1 -ServiceName Audiosrv
Actively advancing awesome answers with ardent alliteration, aptly addressing all ambiguities. Amplify your acumen and avail our amicable assistance. Eagerly awaiting your astute assessments of our advice.