"negative" service check

(Fabian) #1

Hi!

i know its possible to check a windows service using nrpe/nsclient++.

But for some special usage i need to check if a service is NOT running.

My research wasn’t succesful right now…

How can i do that? Any Ideas?

TIA

(Chris) #2

if you use nrpe with the nsclient i use the following to check if a service is disabled and not running:

  vars.nrpe_command = "check_service"
  vars.nrpe_arguments = [ "service=defragsvc" , "crit= state = 'started' or start_type = 'auto'" , "warn=start_type = 'demand'" , "ok= state = 'stopped' and start_type = 'disabled'" , "top-syntax=%(status): %(list)" , "detail-syntax=%(name):%(state):%(start_type)" ]

Just modify this as you need.
In this example i check if the defrag service is disabled and not running

2 Likes
(Fabian) #3

Thanks!
I’ll try it.

(Fabian) #4
object Service "NRPE" {
  import "generic-service"
  host_name = "Customer - EX01"                     
  vars.nrpe_command = "check_service"
  vars.nrpe_arguments = [ "service=Acronis VSS Provider" , "crit= state = 'started'" , "warn= start_type = 'auto'" , "ok= state = 'stopped'" , "top-syntax=%(status): %(list)" , "detail-syntax=%(name):%(state):%(start_type)" ]
}

Am I using this wrong?
It i created it for an example host but it says me:

critical/config: Error: Validation failed for object 'Customer - EX01!NRPE' of type 'Service'; Attribute 'check_command': Attribute must not be empty.
Location: in /etc/icinga2/zones.d/Customer/Customer-EX01.conf: 26:1-26:21
/etc/icinga2/zones.d/Customer/Customer-EX01.conf(24): }
/etc/icinga2/zones.d/Customer/Customer-EX01.conf(25):
/etc/icinga2/zones.d/Customer/Customer-EX01.conf(26): object Service "NRPE" {
                                                       ^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/Customer/Customer-EX01.conf(27):   import "generic-service"
/etc/icinga2/zones.d/Customer/Customer-EX01.conf(28):   host_name = "Customer - EX01"
(Chris) #5

you need to define the check command in your service.

In this case you need:

check_command = "nrpe"

1 Like
(Fabian) #6
Ausgabe des Plugins
Exception processing request: Request command contained illegal metachars!

Now the command reaches the nsclient++, but it gives back an error message.
I already allowed “nasty metachars” in nscp, using:
https://docs.nsclient.org/reference/client/NRPEServer/#command-allow-nasty-meta-chars

(Fabian) #7

Okay it works,

i edited the nsclient.ini of another machine without purpose.:smiley:

#closed

(Fabian) #8

Hi, its me again.

Do you know if it is possible to do the same thing but i want to check a .exe instead of a service?