Recently I wrote about the changes in NSClient++ 0.5.0 and its REST API capabilities. Icinga 2 bundles the NSClient++ installer and additional check commands in the “nscp-local” namespace for your convenience for a while already now.

The documentation highlights a short example for querying performance counters with the Icinga 2 client as command endpoint and local NSClient++ check plugin calls.

While testing the 0.5.0 integration I’ve also taken the steps of adding service checks for every available check command we have added so far to the Icinga 2 template library. I thought sharing this with you will hopefully generate feedback for documentation updates – how you are currently using NSClient++ in combination with the Icinga 2 client?

Requirements

Icinga 2 master and Windows client, configured as command endpoint.

NSClient++ 0.4.x or 0.5.x (requires updated Icinga 2 check commands from #12733 or the recent 2.6 release).

Example Zone/Endpoint configuration on the master:

object Endpoint NodeName {
}

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

object Endpoint "DESKTOP-IHRPO96" {
//client connects itself
}

object Zone "DESKTOP-IHRPO96" {
  endpoints = [ "DESKTOP-IHRPO96" ]
  parent = "master"
}

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

 

Zone/Endpoint configuration on the Windows client (this one accepts both commands and config):

object Endpoint "mbmif.int.netways.de" {
	host = "mbmif.int.netways.de"
	port = "5665"
}

object Zone "master" {
	endpoints = [ "mbmif.int.netways.de" ]
}

object Endpoint NodeName {
}

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

Host Object Configuration

I prefer to specify the operating system type and version as custom attributes, allowing more specific apply rule filters later on. By convention the host object name is the same as the defined endpoint object. That makes it easy to inherit the command endpoint name to services in the “client_endpoint” custom attribute.

object Host "DESKTOP-IHRPO96" {
  address = "10.0.10.36"

  check_command = "hostalive"

  vars.client_endpoint = name

  vars.os_type = "windows"
  vars.os_version = "10"
}

CPU and Memory Service Checks

Nothing more to say, if you need additional thresholds make sure to check the documentation.

/* CPU */
apply Service "nscp-local-cpu" {
  check_command = "nscp-local-cpu"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_cpu_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

/* Memory */
apply Service "nscp-local-memory" {
  check_command = "nscp-local-memory"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_memory_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

OS Version, Pagefile Checks

The OS version should obviously return “Windows 10”. Older NSClient++ versions were irregularly naming it “Windows 8”.

/* OS Version */
apply Service "nscp-local-os-version" {
  check_command = "nscp-local-os-version"
  command_endpoint = host.vars.client_endpoint

  //no nscp_*_showall
  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

/* Pagefile */
apply Service "nscp-local-pagefile" {
  check_command = "nscp-local-pagefile"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

Process and Services

The following examples check all local processes and running services. An additional check for the running security center service has been added too.

/* Process */
apply Service "nscp-local-process" {
  check_command = "nscp-local-process"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

/* Services */
apply Service "nscp-local-service-security-center" {
  check_command = "nscp-local-service"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_service_name = "wscsvc" //security center

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

apply Service "nscp-local-services" {
  check_command = "nscp-local-service"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_service_arguments = [ "exclude=sppsvc", "exclude=ShellHWDetection" ]

  vars.nscp_showall = false

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

This example excludes specific services from being checked.

Uptime and NSClient++ Version

/* Uptime */
apply Service "nscp-local-uptime" {
  check_command = "nscp-local-uptime"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

/* Version */
apply Service "nscp-local-version" {
  check_command = "nscp-local-version"
  command_endpoint = host.vars.client_endpoint

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

Disk Checks

/* Disk */
apply Service "nscp-local-disk" {
  check_command = "nscp-local-disk"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_disk_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

apply Service "nscp-local-disk-C" {
  check_command = "nscp-local-disk"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_disk_showall = true
  vars.nscp_disk_drive = "C"

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

Performance Counters

You’ll need to extract the specific performance counter name from your Windows system. The CPU performance counter includes a percentage sign in its performance data label. That’s known to cause issues with Graphite and other TSDBs – you can read the full story here.

Note: The “perfsyntax” parameter changed in NSClient++ 0.5.0. Requires an updated Icinga 2 version v2.6+ including check commands from #12733.

/* Performance counters */
apply Service "nscp-local-counter-cpu" {
  check_command = "nscp-local-counter"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_counter_name = "\\Processor(_total)\\% Processor Time"
  vars.nscp_counter_perfsyntax = "Total Processor Time"
  vars.nscp_counter_warning = 1
  vars.nscp_counter_critical = 5

  vars.nscp_counter_showall = true

  assign where host.vars.client_endpoint && host.vars.os_type == "windows"
}

Conclusion

This is a simple example for just one Windows client. The apply rules are just defined once, start adding new Icinga 2 Windows client hosts and have all services applied to them. Enjoy the power of Icinga 2 and NSClient++ :-)

There are more things coming in the future integrating the NSClient++ REST API even more. We’ll keep you posted.

icinga2_nsclient_0-5-0_nscp_local_checks_icingaweb2