Nrpe-check works but fails with arguments

I’m struggling with nrpe while switching from icinga1 to icinga2.

The machines are configured and the Checks work on Icinga1.

I configured my first Check in Icinga2 which is a simple nrpe-check without arguments. That works.
I configured a service-template and an apply-rule.

See the config of the nrpe-command:

object CheckCommand "nrpe" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_nrpe" ]
    timeout = 5m
    arguments += {
        "-2" = {
            description = "Use this if you want to connect to NRPE v2"
            set_if = "$nrpe_version_2$"
        }
        "-4" = {
            description = "Use IPv4 connection"
            set_if = "$nrpe_ipv4$"
        }
        "-6" = {
            description = "Use IPv6 connection"
            set_if = "$nrpe_ipv6$"
        }
        "-H" = {
            description = "The address of the host running the NRPE daemon"
            value = "$nrpe_address$"
        }
        "-a" = {
            order = 1
            repeat_key = false
            value = "$nrpe_arguments$"
        }
        "-c" = "$nrpe_command$"
        "-n" = {
            description = "Do not use SSL"
            set_if = "$nrpe_no_ssl$"
        }
        "-p" = "$nrpe_port$"
        "-t" = {
            description = "<interval>:<state> = <Number of seconds before connection times out>:<Check state to exit with in the event of a timeout (default=CRITICAL)>"
            value = "$nrpe_timeout$"
        }
        "-u" = {
            description = "Make socket timeouts return an UNKNOWN state instead of CRITICAL"
            set_if = "$nrpe_timeout_unknown$"
        }
    }
    vars.check_address = {
        arguments = [  ]
        deprecated = false
        name = "<anonymous>"
        side_effect_free = false
        type = "Function"
    }
    vars.check_ipv4 = "$nrpe_ipv4$"
    vars.check_ipv6 = "$nrpe_ipv6$"
    vars.nrpe_address = "$check_address$"
    vars.nrpe_no_ssl = false
    vars.nrpe_timeout_unknown = false
    vars.nrpe_version_2 = false
}

…and the check itself:

template Service "win-cpu" {
   check_command = "nrpe"
   check_period = "24x7"
   enable_notifications = true
   enable_active_checks = true
   enable_passive_checks = true
   enable_event_handler = true
   enable_flapping = true
   enable_perfdata = true
   command_endpoint = null
   vars.nrpe_command = "alias_cpu"
   vars.nrpe_port = "778"
   }

I then wanted to implement my second check which will be applied to the same machine with the same procedure. This Check will have two additional arguments (seperated by space?)

This Check fails and results in state “UNKNOWN” with the error-message:
execvpe(/usr/lib/nagios/plugins/check_nrpe) failed: no such file or directory
the check is configured as follows:

template Service "sql_check" {
    check_command = "nrpe"
    check_period = "24x7"
    enable_notifications = true
    enable_active_checks = true
    enable_passive_checks = true
    enable_event_handler = true
    enable_flapping = true
    enable_perfdata = true
    volatile = true
    command_endpoint = null
    vars.nrpe_arguments = "ShowAll SQLSERVERAGENT"
    vars.nrpe_command = "CheckServiceState"
    vars.nrpe_port = "778"
}

which to me seems like the check tries to execute check_nrpe on the target machine. That clearly can’t work but I’m asking myself why icinga2 even tries to do that as it does what it should do in the first check.

the two service-templates are completely the same and use the same command, except the second one uses an additional parameter.

Please show the full service object compiled, e.g. from icinga2 object list --type Service --name ....

Here is the ouput of:
icinga2 object list --type Service --name win-cpu

Object 'srv123-mmap.test.domain!win-cpu' of type 'Service':
  % declared in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * __name = "srv123-mmap.test.domain!win-cpu"
  * action_url = ""
  * check_command = "nrpe"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 2:5-2:26
  * check_interval = 300
  * check_period = "24x7"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 3:5-3:25
  * check_timeout = null
  * command_endpoint = ""
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 10:5-10:27
  * display_name = "win-cpu"
  * enable_active_checks = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 5:5-5:31
  * enable_event_handler = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 7:5-7:31
  * enable_flapping = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 8:5-8:26
  * enable_notifications = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 4:5-4:31
  * enable_passive_checks = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 6:5-6:32
  * enable_perfdata = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 9:5-9:26
  * event_command = ""
  * flapping_threshold = 0
  * flapping_threshold_high = 30
  * flapping_threshold_low = 25
  * groups = [ ]
  * host_name = "srv123-mmap.test.domain"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * icon_image = ""
  * icon_image_alt = ""
  * max_check_attempts = 3
  * name = "win-cpu"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * notes = ""
  * notes_url = ""
  * package = "director"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * retry_interval = 60
  * source_location
    * first_column = 0
    * first_line = 1
    * last_column = 22
    * last_line = 1
    * path = "/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf"
  * templates = [ "win-cpu", "win-cpu", "host var overrides (Director)" ]
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 1:0-1:25
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/director-global/001-director-basics.conf', lines 16:3-16:59
  * type = "Service"
  * vars
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/director-global/001-director-basics.conf', lines 26:7-26:51
    * nrpe_command = "alias_cpu"
      % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 11:5-11:35
    * nrpe_port = "777"
      % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 12:5-12:26
  * volatile = false
  * zone = "master"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22

Object 'srv124-mmdb.test.domain!win-cpu' of type 'Service':
  % declared in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * __name = "srv124-mmdb.test.domain!win-cpu"
  * action_url = ""
  * check_command = "nrpe"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 2:5-2:26
  * check_interval = 300
  * check_period = "24x7"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 3:5-3:25
  * check_timeout = null
  * command_endpoint = ""
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 10:5-10:27
  * display_name = "win-cpu"
  * enable_active_checks = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 5:5-5:31
  * enable_event_handler = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 7:5-7:31
  * enable_flapping = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 8:5-8:26
  * enable_notifications = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 4:5-4:31
  * enable_passive_checks = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 6:5-6:32
  * enable_perfdata = true
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 9:5-9:26
  * event_command = ""
  * flapping_threshold = 0
  * flapping_threshold_high = 30
  * flapping_threshold_low = 25
  * groups = [ ]
  * host_name = "srv124-mmdb.test.domain"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * icon_image = ""
  * icon_image_alt = ""
  * max_check_attempts = 3
  * name = "win-cpu"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * notes = ""
  * notes_url = ""
  * package = "director"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
  * retry_interval = 60
  * source_location
    * first_column = 0
    * first_line = 1
    * last_column = 22
    * last_line = 1
    * path = "/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf"
  * templates = [ "win-cpu", "win-cpu", "host var overrides (Director)" ]
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 1:0-1:25
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/director-global/001-director-basics.conf', lines 16:3-16:59
  * type = "Service"
  * vars
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/director-global/001-director-basics.conf', lines 26:7-26:51
    * nrpe_command = "alias_cpu"
      % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 11:5-11:35
    * nrpe_port = "777"
      % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_templates.conf', lines 12:5-12:26
  * volatile = false
  * zone = "master"
    % = modified in '/var/lib/icinga2/api/packages/director/33aa4322-4069-44ea-a1bb-d38cdda90e77/zones.d/ccsp-domain/service_apply.conf', lines 1:0-1:22

Strangely, there is no output for the other command :confused:

The Service-Command that is triggered looks suspicious to me but I have no Idea why and I don’t know -if it’s the error- how to fix it:
curl -s -X POST -H 'Accept: application/json' -k -u 'root':'password' -d '{"next_check":1537972866,"force":true,"service":"srv123-mmap.test.domain!sql_check SQLSERVERAGENT Check"}' 'https://icingamaster1.server.lan:5665/v1/actions/reschedule-check'

nrpe_arguments needs to be an array

   vars.nrpe_arguments = [ "arg1", "arg2", ...]
1 Like

Thanks for the hint. Does that mean, I have to create my own nrpe-command on top of the existing (external) nrpe-command icinga2 came with?
I’m asking because I can’t see how I can add “nrpe_arguments” as an array to the existing external command.

Try this:

object Host             "Hostname" {
    import              "windows-ext"
    address =           "172.00.000.00"
    notes =             ""
    vars.storage =      [ "c", "d" ]
    vars.service =      [
                        "OfficeMaster Converter",
                        "OfficeMaster msx2kgate0",
                        "fmsrv",
                        "OMSysLog",
                        "XCAPIService"
                        ]
}

apply Service "service-windows-" for (service_name in host.vars.service) {
        import "generic-service"
        check_command = "nrpe"

        vars.nrpe_command =     "CheckServiceState"
        vars.nrpe_arguments =    service_name
        vars.nrpe_no_ssl =           true
        vars.sla =                          host.vars.sla

        assign where host.address && host.vars.os == "windows"
}
1 Like