Problem: Check running services on Windows client

Hi icinga community,

I started monitoring several Linux and Windows systems with icinga2.
I would like to check, if a certain service is running on the client (just one).

On Linux it works fine, but I’m struggling to monitor running services on Windows

This is what I got:

apply Service "service-mssql" {
  check_command = "procs"
  command_endpoint = host.vars.client_endpoint
  vars.procs_command = "mssql"
  vars.procs_critical = "0:2"
  vars.procs_warning = "1:1"

  assign where host.vars.servicecheck == "mssql"
}

Error message:
Unbenannt

The state of the serivce is “UNKNOWN”
plugin output: unrecognised option '-C'

Some Information:
The Icinga 2 network monitoring daemon (version: r2.12.3-1)

System information:

  • Platform: Debian GNU/Linux
  • Platform version: 10 (buster)
  • Kernel: Linux
  • Kernel version: 4.19.0-9-amd64

Enabled features:
api checker ido-mysql mainlog notification

Config validation doesn’t give any errors, looks fine.

It only exists one master zone(parent) and one client zone(child)

Seems like I give the wrong parameters or variables for critial warning?? Can you help here?

Thank you very much in advance!!

Hi & welcome to the icinga community,

You’re trying to run a Linux command on a Windows machine. Please try service-windows instead.

Hi Roland, thanks for your quick reply. I’m sorry, but I’m fairly new with icinga. I’ve read the instructions for “service-windows” but they’re not entirely clear to me.

I installed Icinga2 on the windows client. But how can I execute the service or where can I find it on the system? (My master is a Linux system though)

You need to configure distributed monitoring and then configure a service object for your windows machine.

The distributed monitoring is already set up, there’s also other basic checks running on the windows machine already (e.g. ping4/load/disc).
But to execute those I only added a few lines in the Service.conf as I also tried for the service check with a Linux command. But I can’t see, how to run this check now for Windows.

For commands running on a Windows machine locally you need to add to your service object:

command_endpoint = host.name

apply Service "service-mssql" {
  check_command = "procs"
  command_endpoint = host.name  
  vars.procs_command = "mssql"
  vars.procs_critical = "0:2"
  vars.procs_warning = "1:1"

  assign where host.vars.servicecheck == "mssql"
}

I changed the line host.vars.client_endpoint to command_endpoint = host.name

Still I’m facing the same problem…

object Endpoint "ms2019p-xpertdb.domain.de" {
    host = "ms2019p-xpertdb.domain.de"
}

object Host "ms2019p-xpertdb.domain.de" {
  import "generic-host"
  import "windows-host-new"
  display_name         = "ms2019p-xpertdb"
  address              = "X.X.X.X"
  check_command        = "hostalive"
  notes                = "Xpert DB-Server"
  vars.client_endpoint = name
  vars.servicecheck = "mssql"
}

And the imported template:
template Host “windows-host-new” {

  vars.os     = "windows-new"
  vars.group  = "windows-servers"
  vars.ping   = "yes"
  vars.disk   = "no"

  vars.notification["mail_host"] = {
    groups = [ "winadmins", "webadmins" ]
  }
  vars.notification["sms_host_workhours"] = {
    groups = [ "winadmins" ]
  }
  vars.notification["mail_service"] = {
    groups = [ "winadmins" ]
  }

  vars.disks_windows["disk C:"] = {
    disk_win_path = "C:",
    disk_win_warn = "5%"
    disk_win_crit = "3%"
  }

   vars.load_wload1  = "86"
   vars.load_cload1  = "96"

   vars.memutil_warn = "15%" //different threshold than the default
   vars.memutil_crit = "5%" //different threshold than the default
}

Zone and endpoint objects have to be defined in zones.conf only (since V2.11).

Best practice is to have check(s) for zones with cluster or cluster-zone. Your check will only be scheduled when the agent is connected.

I’m sorry, but I still don’t see how that solves my problem :frowning: What is wrong with my definition of the service object, that I still get the “Unkown Error”.
The client is installed on windows system and connected to the master, distributed monitoring was also set up, local checks like storage or load checks work fine. I also followed your advises and moved the object endpoint into zones.conf and replaced the line “command_endpoint = host.name” within the service object.
It only exist two zones (master zone and zone “Visable” where all hosts are listed"

This is how my zones.conf looks like:

object Endpoint NodeName {
  host =  NodeName
}

object Zone "master" {
  endpoints = [ NodeName ]
}

object Zone "global-templates" {
  global = true
}

object Zone "director-global" {
  global = true
}



object Endpoint "ms2019p-xpertdb.domain.de" {
    host = "ms2019p-xpertdb.domain.de"
}

object Zone "Visable" {
    parent = "master"
    endpoints = ["ms2019p-xpertdb.domain.de" ]
}

My service in “windows_services.conf” looks as follow:

apply Service "service-mssql" {
  check_command = "procs"
  vars.procs_command = "MSSQLSERVER"
  command_endpoint = host.name
  vars.procs_critical = "0:2"
  vars.procs_warning = "1:1"

  assign where host.vars.servicecheck == "mssql"
}

While my “windows_hosts.conf” contains:

object Endpoint "ms2019p-xpertdb.domain.de" {
    host = "ms2019p-xpertdb.domain.de"
}

object Host "ms2019p-xpertdb.domain.de" {
  import "generic-host"
  import "windows-host-new"
  display_name         = "ms2019p-xpertdb"
  address              = "X.X.X.X"
  check_command        = "hostalive"
  notes                = "Xpert DB-Server"
  vars.client_endpoint = name
  vars.servicecheck = "mssql"
}

I just want to monitor this single windows client

As already mentioned, endpoint objects have to be defined in zones.conf only.

Sorry, my bad it was an older copy. The object endpoint is only defined in zones.conf.
It is still not working and shows the same error.

object Endpoint "ms2019p-xpertdb.domain.de" {
    host = "ms2019p-xpertdb.domain.de"
}

Okay I removed the entire thing and did it from scratch again, here’s what I did:

Setup Icinga on Windows:

  1. Downloaded and installed Icinga2 on Windows client
  2. Started the Icinga2 Wizard, added the “master” zone as parent
  3. Activated “Listen for connections” on Port 5665
  4. Actived the two checks “Accept commands from master” and “Accept config updated from master”
  5. Deleted the “checker.conf” in c://programdata/icinga2/etc/icinga2/features-enabled (I’ve been told to do so as it’s not working otherwise)
  6. Checked Firewall rules, so communication to host is possible (I activated the “File-and Print Sharing” in Windows Firewall)
  7. On the Icinga-Host I signed the new fingerprint

Setup the new client:

  1. Created a little template for future Windows systems (see below #1)
  2. I created a new config file for Windows systems, called “Win_new.conf” and configured the host (see below #2)
  3. I edited the zones.conf and entered a new endpoint for new client and added the endpoint to the zone “Visable” that already existed and contains all monitored hosts (see below #3)

Setup the new service-check:

  1. Finally I created a new config file “Win_new_services.conf” (see below #4)
  2. I entered the new service check as you advised.

I did everything, you told me, set up the endpoint only in zones.conf and changed the line host.vars.client_endpoint to command_endpoint = host.name. Still I’m getting the same error, the service exists, but somehow data can’t be accessed and the service is shown as “Unkown”

This is how it looks:

#1 Template (icinga2/conf.d/templates):

#########################################################
# Template Windows Host NEW
#########################################################
 template Host "windows-host-new" {

   vars.os     = "windows-new"
   vars.group  = "windows-servers"
   vars.ping   = "yes"
   vars.disk   = "no"

   vars.notification["mail_host"] = {
     groups = [ "winadmins", "webadmins" ]
   }
   vars.notification["sms_host_workhours"] = {
     groups = [ "winadmins" ]
   }
   vars.notification["mail_service"] = {
     groups = [ "winadmins" ]
   }

   vars.disks_windows["disk C:"] = {
     disk_win_path = "C:",
     disk_win_warn = "5%"
     disk_win_crit = "3%"
   }

    vars.load_wload1  = "86"
    vars.load_cload1  = "96"

    vars.memutil_warn = "15%" //different threshold than the default
    vars.memutil_crit = "5%" //different threshold than the default
 }

#2 Client Setup (icinga2/zones.d/master/Hosts/Win_new)

object Host "ms2019p-xpertdb.domain.de" {
  import "generic-host"
  import "windows-host-new"
  display_name         = "ms2019p-xpertdb"
  address              = "X.X.X.X"
  check_command        = "hostalive"
  notes                = "Xpert DB-Server"
  vars.client_endpoint = name
  vars.servicecheck = "smartflow"

  vars.disks_windows["disk D:"] = {
    disk_win_path = "D:"
    disk_win_warn = "5%"
    disk_win_crit = "3%"
  }
}

#3 zones.conf (icinga2/zones.conf)

object Endpoint NodeName {
  host =  NodeName
}

object Zone "master" {
  endpoints = [ NodeName ]
}

object Zone "global-templates" {
  global = true
}

object Zone "director-global" {
  global = true
}

object Endpoint "ms2019p-xpertdb.domain.de" {
     host = "ms2019p-xpertdb.domain.de"
 }

object Zone "Visable" {
    parent = "master"
    endpoints = ["ms2019p-xpertdb.domain.de"]
}

#4 (icinga2/zones.d/Services/Win_new_services.conf)

apply Service "service-smartflow" {
  check_command = "procs"
  command_endpoint = host.name
  vars.procs_command = "smartflow-server"
  vars.procs_critical = "0:2"
  vars.procs_warning = "1:1"

  assign where host.vars.servicecheck == "smartflow"
}

Note: the list of endpoints and endpoints in Visable-zone is longer, for better overview I just extracted the current problem ms2019p-xpertdb server

Is there any ideas on where the mistake is located or what I can do to figure it out. I’d be very grateful if someone can help me out.

Thank you and kind regards
Kevin

You’re still using a Linux command for a Windows host. I’m out.
Please be aware that every agent needs its own zone end endpoint.