Icinga2 Custom Pluggins to Add in Check_command

Hi,

I’ve recently updated the corresponding docs for plugins and their integration, please read them if you haven’t done this yet.

I’m not sure what exactly

but under ITL templates check_command & arguments are different approach as below.

means … you’re referring to check_cpu.sh while the check command example refers to check_cpu_usage as script. Is that the same and just renamed?

If so, please keep a note on the parameter names as well as the check command name. There are certain best practices on the naming schema here, e.g. using the descriptive way like this instead of the load_prefixed parameters.

object CheckCommand "cpu_usage" {
  command = [ PluginDir + "/check_cpu_usage" ]

  arguments = {
    "-w" = {
      value = "$cpu_usage_wload1$,$cpu_usage_wload5$,$cpu_usage_wload15$"
      description = "Exit with WARNING status if load average exceeds WLOADn"
    }
    "-c" = {
      value = "$cpu_usage_cload1$,$cpu_usage_cload5$,$cpu_usage_cload15$"
      description = "Exit with CRITICAL status if load average exceeds CLOADn"
    }
    "-r" = {
      set_if = "$cpu_usage_percpu$"
      description = "Divide the load averages by the number of CPUs (when possible)"
    }
  }

  // Set some default values
  vars.cpu_usage_wload1 = 1
  vars.cpu_usage_wload5 = ...
}

For a service apply rule, go with this:

apply Service "cpu-usage" {
  check_command = "cpu_usage"

  vars.cpu_usage_wload1 = ...
  vars.cpu_usage_wload5 = ...
  vars.cpu_usage_wload10 = ...

  assign where host.vars.os_type == "Linux" //or a different pattern
}

Try that - the corresponding configuration (commands, apply rules, etc.) should be put into an included directory from your icinga2.conf. If you’re planning with a distributed setup with agents, put them into a global zone, e.g. zones.d/global-templates/commands.conf.

Cheers,
Michael