Simple CPU Monitoring via nscp-local-cpu?

New to icinga so go easy :slight_smile:

I’m pulling in what I thought would be CPU usage via nscp-local-cpu, even though the processor isn’t being hit hard, it’s flagged as critical and just displays the disk stats again as in the screenshot attached?

Probably me completely missing the point again but thought I’d reach out for help!



nscp-local-cpu has a design flaw, as it only takes a short snapshot. In order to measure the CPU load, you’ll need to hold and calculate performance counters over time, and calculate the average from it. This is what NSClient++ does as a service and was the main motivation behind development check_nscp_api querying its REST API.

The instructions for a local setup can be found inside the docs. First off, ensure that NSClient++ has an API password set during the setup routine. You can also do that manually as described in its docs.

Then you’ll integrate the provided CheckCommand into an actual service like described here. The main difference are the command arguments, modify them like this:

object Host "windows-host.fqdn" {
  address = "..."
  vars.client_endpoint = name //requires the endpoint object called 'windows-host.fqdn'

  vars.nscp_api_password = NscpApiPassword //define this constant in constants.conf

  vars.os_type = "windows"

apply Service "cpu" {
  import "generic-service"

  check_command = "nscp_api"
  command_endpoint = host.vars.client_endpoint

  vars.nscp_api_host = "localhost"
  vars.nscp_api_password = host.vars.nscp_api_password //will be hidden in Icinga Web 2's detail view by default (security config)

  vars.nscp_api_query = "check_cpu"
  vars.nscp_api_arguments = [ "warning=load>1", "critical=load>20" ]

  assign where host.vars.os_type == "windows"


1 Like

Thanks for your help, really useful.

Next challenge, sorting the check_nscp_api, not sure there is a way of enabling this on install as part of the icinga2-powershell-module.

When NSClient++ is installed (and it already is since you’re using nscp-local-cpu), you can use the linked command to enable this via CLI (and add this to your script calls after the main PS script).

nscp web install --password <MY SECURE API KEY>

Keep in mind that the API enabled here has no permission system (yet, Michael is working on that), so you’ll get everything (even stopping the service) or nothing. That is why the above examples still use Icinga 2 as client command endpoint and only query the service locally.


1 Like