Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

[dev.icinga.com #12595] Multiple NRPE arguments are merged into one argument #425

Closed icinga-migration closed 8 years ago

icinga-migration commented 8 years ago

This issue has been migrated from Redmine: https://dev.icinga.com/issues/12595

Created by log1c on 2016-08-30 13:52:59 +00:00

Assignee: (none) Status: Resolved (closed on 2016-09-06 15:04:00 +00:00) Target Version: (none) Last Update: 2016-09-06 15:04:00 +00:00 (in Redmine)


Hi,

I'm not 100% sure if it is a bug or rather a feature request:

I'm using the nrpe command imported from icinga2 in icinga Director. If I now add a service that requires mutliple arguments I simply write all of them into the nrpe_argument field, seperated by a space.

Configured like that, these checks do not work, because the director merges all arguments into one single argument:

apply Service "Email Heartbeat ST-FIL01" {
    import "NRPE generic Check"
    vars.nrpe_arguments = "xxx yyy INFO RECEIVE 10140"
    vars.nrpe_command = "EmailHeartbeat"
    vars.nrpe_timeout = "30"
    assign where "Exchange Server from Central" in host.templates
}

I also tried seperating the arguments by commas, using single or double quotation marks around each argument and a tried combining this with square brackets. Without any success.

Best Regards, Logic

icinga-migration commented 8 years ago

Updated by log1c on 2016-08-30 13:56:10 +00:00

Forgot to mention that I use v1.1.0 of Icinga Director and v2.3.3 of Icinga2/IcingaWeb2

icinga-migration commented 8 years ago

Updated by log1c on 2016-09-06 13:03:41 +00:00

It seems like this problem is not limited to NRPE but all argument fields. This seems to work for ip-addresses seperated by comma, or load values seperated by comma but not for, e.g. a list of vServices seperated by comma:

If I specifiy the following services to be excluded by check_loadmaster.pl command

"Exchange 2016 HTTPS Offloaded - OAB","Exchange 2010 HTTPS Offloaded with ESP - ECP","Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy"

I get this config preview with "one" exclude-services-argument

object Service "Load" {
    host_name = "Kemp Loadmaster"
    check_command = "check_loadmaster"
    max_check_attempts = "3"
    check_interval = 5m
    retry_interval = 1m
    enable_notifications = true
    enable_active_checks = true
    enable_passive_checks = false
    enable_event_handler = true
    enable_perfdata = true
    volatile = false
    vars.critical = "2,4,6"
    vars.kemp_ignore_hosts = "192.168.100.180,192.168.100.186,192.168.100.168,192.168.100.157,192.168.100.158"
    vars.kemp_ignore_services = "\"Exchange 2016 HTTPS Offloaded - OAB\",\"Exchange 2010 HTTPS Offloaded with ESP - ECP\",\"Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy\""
    vars.warning = "1,3,5"
}
icinga-migration commented 8 years ago

Updated by tgelf on 2016-09-06 13:09:53 +00:00

Please read this chapter from the documentation...

https://github.com/Icinga/icingaweb2-module-director/blob/master/doc/14-Fields-example-interfaces-array.md

...and let me know if it solves your problem. In Icinga 2 all command arguments are escaped per default, that's just how it should work.

icinga-migration commented 8 years ago

Updated by log1c on 2016-09-06 13:32:21 +00:00

sadly it doesn't solve the problem. Though the config looks as described.

object Service "Load" {
    host_name = "Kemp Loadmaster"
    import "Kemp Loadmaster Checks"

    vars.critical = "2,4,6"
    vars.kemp_ignore_hosts = [
        "192.168.100.180",
        "192.168.100.186",
        "192.168.100.168",
        "192.168.100.157",
        "192.168.100.158"
    ]
    vars.kemp_ignore_services = [
        "Exchange 2016 HTTPS Offloaded - OAB",
        "Exchange 2010 HTTPS Offloaded with ESP - ECP",
        "Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy",
        "Exchange 2016 HTTPS Offloaded - EWS",
        "Servicedesk Intern",
        "Exchange 2010 HTTPS Offloaded with ESP - ActiveSync",
        "Exchange 2016 HTTPS Offloaded - MAPI",
        "Exchange 2016 HTTPS Reencrypted with ESP - ECP",
        "Servicedesk Authentication Proxy",
        "Exchange 2010 HTTPS Offloaded with ESP - Autodiscover",
        "Exchange 2016 HTTPS Reencrypted with ESP - Autodiscover",
        "Exchange 2010 HTTPS Offloaded with ESP - EWS",
        "Servicedesk HTTP Redirect",
        "Exchange 2016 HTTPS Offloaded",
        "Exchange 2016 HTTPS Reencrypted with ESP",
        "Exchange 2010 HTTPS Offloaded with ESP - OAB",
        "Exchange 2010 HTTPS Offloaded with ESP - OWA",
        "Exchange 2016 HTTPS Offloaded - RPC",
        "Exchange 2016 HTTPS Reencrypted with ESP - RPC",
        "Servicedesk",
        "Exchange 2016 HTTPS Reencrypted with ESP - OWA",
        "Exchange 2016 HTTPS Offloaded - Autodiscover",
        "Exchange 2010 HTTPS Offloaded with ESP - PowerShell",
        "Exchange 2016 HTTPS Reencrypted with ESP - MAPI",
        "Exchange 2016 HTTPS Reencrypted with ESP - Authentication Proxy",
        "Exchange HTTP Redirect",
        "Helpdesk",
        "Intranet Services HTTP Redirect",
        "Exchange 2016 HTTPS Offloaded - ActiveSync",
        "Exchange 2010 HTTPS Offloaded with ESP - RPC",
        "Exchange 2016 HTTPS Offloaded - HTTP Redirect",
        "Exchange 2016 HTTPS Reencrypted with ESP - EWS",
        "Servicedesk Extern",
        "Exchange 2016 HTTPS Reencrypted with ESP - HTTP Redirect",
        "Servicedesk Change Password",
        "Exchange 2016 HTTPS Offloaded - OWA",
        "Exchange 2016 HTTPS Reencrypted with ESP - ActiveSync",
        "Exchange",
        "Exchange 2016 HTTPS Reencrypted with ESP - OAB",
        "Intranet Services",
        "Exchange 2016 HTTPS Offloaded - ECP",
        "Exchange 2016 HTTPS Reencrypted with ESP - PowerShell",
        "Exchange 2016 HTTPS Offloaded - PowerShell"
    ]
    vars.warning = "1,3,5"
}

The script itself works fine if executed from the command line.

I will make further test later this week. A workaround for me could be to let the script get executed via nrpe.

thanks and greetings!

icinga-migration commented 8 years ago

Updated by tgelf on 2016-09-06 13:35:10 +00:00

Could you please show me the related command definition?

icinga-migration commented 8 years ago

Updated by log1c on 2016-09-06 13:53:08 +00:00

object CheckCommand "check_loadmaster" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_loadmaster.pl" ]
    arguments = {
        "-C" = {
            repeat_key = false
            required = true
            value = "$snmpcommunity$"
        }
        "-H" = {
            repeat_key = false
            required = true
            value = "$address$"
        }
        "-I" = {
            repeat_key = false
            required = false
            value = "$kemp_ignore_hosts$"
        }
        "-c" = {
            repeat_key = false
            required = false
            value = "$critical$"
        }
        "-i" = {
            repeat_key = false
            required = true
            value = "$kemp_ignore_services$"
        }
        "-w" = {
            repeat_key = false
            required = false
            value = "$warning$"
        }
    }
}
icinga-migration commented 8 years ago

Updated by tgelf on 2016-09-06 13:56:11 +00:00

Ok, looks good to me. Could you please click on "Inspect" from the monitoring details page of such a service and show me what last_check_result -> command is telling you? And please also show me how you want the command to be executed instead.

icinga-migration commented 8 years ago

Updated by log1c on 2016-09-06 14:01:43 +00:00

last_check_result: {
      active: true,
      check_source: "st-mon2-rz.stemmer.loc",
      command: [
        "/usr/lib/nagios/plugins/check_loadmaster.pl",
        "-C",
        "public",
        "-H",
        "192.168.101.67",
        "-I",
        "192.168.100.180",
        "192.168.100.186",
        "192.168.100.168",
        "192.168.100.157",
        "192.168.100.158",
        "-c",
        "2,4,6",
        "-i",
        "Exchange 2016 HTTPS Offloaded - OAB",
        "Exchange 2010 HTTPS Offloaded with ESP - ECP",
        "Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy",
        "Exchange 2016 HTTPS Offloaded - EWS",
        "Servicedesk Intern",
        "Exchange 2010 HTTPS Offloaded with ESP - ActiveSync",
        "Exchange 2016 HTTPS Offloaded - MAPI",
        "Exchange 2016 HTTPS Reencrypted with ESP - ECP",
        "Servicedesk Authentication Proxy",
        "Exchange 2010 HTTPS Offloaded with ESP - Autodiscover",
        "Exchange 2016 HTTPS Reencrypted with ESP - Autodiscover",
        "Exchange 2010 HTTPS Offloaded with ESP - EWS",
        "Servicedesk HTTP Redirect",
        "Exchange 2016 HTTPS Offloaded",
        "Exchange 2016 HTTPS Reencrypted with ESP",
        "Exchange 2010 HTTPS Offloaded with ESP - OAB",
        "Exchange 2010 HTTPS Offloaded with ESP - OWA",
        "Exchange 2016 HTTPS Offloaded - RPC",
        "Exchange 2016 HTTPS Reencrypted with ESP - RPC",
        "Servicedesk",
        "Exchange 2016 HTTPS Reencrypted with ESP - OWA",
        "Exchange 2016 HTTPS Offloaded - Autodiscover",
        "Exchange 2010 HTTPS Offloaded with ESP - PowerShell",
        "Exchange 2016 HTTPS Reencrypted with ESP - MAPI",
        "Exchange 2016 HTTPS Reencrypted with ESP - Authentication Proxy",
        "Exchange HTTP Redirect",
        "Helpdesk",
        "Intranet Services HTTP Redirect",
        "Exchange 2016 HTTPS Offloaded - ActiveSync",
        "Exchange 2010 HTTPS Offloaded with ESP - RPC",
        "Exchange 2016 HTTPS Offloaded - HTTP Redirect",
        "Exchange 2016 HTTPS Reencrypted with ESP - EWS",
        "Servicedesk Extern",
        "Exchange 2016 HTTPS Reencrypted with ESP - HTTP Redirect",
        "Servicedesk Change Password",
        "Exchange 2016 HTTPS Offloaded - OWA",
        "Exchange 2016 HTTPS Reencrypted with ESP - ActiveSync",
        "Exchange",
        "Exchange 2016 HTTPS Reencrypted with ESP - OAB",
        "Intranet Services",
        "Exchange 2016 HTTPS Offloaded - ECP",
        "Exchange 2016 HTTPS Reencrypted with ESP - PowerShell",
        "Exchange 2016 HTTPS Offloaded - PowerShell",
        "-w",
        "1,3,5"
      ],

If I execute the script with the same arguemnts from the command line, the service returns an OK-State instead of Critical, when it is exectued by Icinga

./check_loadmaster.pl -H 192.168.101.67 -C public -I 192.168.100.180,192.168.100.186,192.168.100.168,192.168.100.157,192.168.100.158 -i "Exchange 2016 HTTPS Offloaded - OAB","Exchange 2010 HTTPS Offloaded with ESP - ECP","Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy","Exchange 2016 HTTPS Offloaded - EWS","Servicedesk Intern","Exchange 2010 HTTPS Offloaded with ESP - ActiveSync","Exchange 2016 HTTPS Offloaded - MAPI","Exchange 2016 HTTPS Reencrypted with ESP - ECP","Servicedesk Authentication Proxy","Exchange 2010 HTTPS Offloaded with ESP - Autodiscover","Exchange 2016 HTTPS Reencrypted with ESP - Autodiscover","Exchange 2010 HTTPS Offloaded with ESP - EWS","Servicedesk HTTP Redirect","Exchange 2016 HTTPS Offloaded","Exchange 2016 HTTPS Reencrypted with ESP","Exchange 2010 HTTPS Offloaded with ESP - OAB","Exchange 2010 HTTPS Offloaded with ESP - OWA","Exchange 2016 HTTPS Offloaded - RPC","Exchange 2016 HTTPS Reencrypted with ESP - RPC","Servicedesk","Exchange 2016 HTTPS Reencrypted with ESP - OWA","Exchange 2016 HTTPS Offloaded - Autodiscover","Exchange 2010 HTTPS Offloaded with ESP - PowerShell","Exchange 2016 HTTPS Reencrypted with ESP - MAPI","Exchange 2016 HTTPS Reencrypted with ESP - Authentication Proxy","Exchange HTTP Redirect","Helpdesk","Intranet Services HTTP Redirect","Exchange 2016 HTTPS Offloaded - ActiveSync","Exchange 2010 HTTPS Offloaded with ESP - RPC","Exchange 2016 HTTPS Offloaded - HTTP Redirect","Exchange 2016 HTTPS Reencrypted with ESP - EWS","Servicedesk Extern","Exchange 2016 HTTPS Reencrypted with ESP - HTTP Redirect","Servicedesk Change Password","Exchange 2016 HTTPS Offloaded - OWA","Exchange 2016 HTTPS Reencrypted with ESP - ActiveSync","Exchange","Exchange 2016 HTTPS Reencrypted with ESP - OAB","Intranet Services","Exchange 2016 HTTPS Offloaded - ECP","Exchange 2016 HTTPS Reencrypted with ESP - PowerShell","Exchange 2016 HTTPS Offloaded - PowerShell"
icinga-migration commented 8 years ago

Updated by tgelf on 2016-09-06 14:10:35 +00:00

This is not the same call, with the given commands Icinga should run -I "192.168.100.180" "192.168.100.186" "192.168.100.168" "192.168.100.157" "192.168.100.158". To get -I 192.168.100.180,192.168.100.186,192.168.100.168,192.168.100.157,192.168.100.158 your vars.kemp_ignore_hosts must be a string reading "192.168.100.180,192.168.100.186,192.168.100.168,192.168.100.157,192.168.100.158"

icinga-migration commented 8 years ago

Updated by log1c on 2016-09-06 14:21:27 +00:00

yes, that is what I had before. The kemp_ignored_hosts isn't the problem though. The hosts I specify there are irgnored and not listed in the check result. As I see it the kemp_ignored_services variable, or more like the "-i" parameter works the same way. All the services I specified in the array are listed in the check result and therefore not excluded from the service.

Here is the check result from icinga:

CRITICAL: LoadBalancer: ST-​KEMP01-​RZ *Master* Uptime: 56 days, 01:​48:​17.​86 Load: 0.​05, 0.​15, 0.​20
Real Server (5)​: 

Virtual Services (43)​: 
"Servicedesk Intern"=inService "Exchange 2010 HTTPS Offloaded with ESP - OAB"=disabled "Exchange 2016 HTTPS Reencrypted with ESP - ECP"=inService "Exchange 2016 HTTPS Offloaded - OWA"=inService "Exchange 2016 HTTPS Reencrypted with ESP - OWA"=inService "Exchange 2016 HTTPS Reencrypted with ESP"=inService "Servicedesk HTTP Redirect"=redirect "Exchange 2016 HTTPS Reencrypted with ESP - EWS"=inService "Exchange 2016 HTTPS Reencrypted with ESP - Autodiscover"=inService "Exchange 2010 HTTPS Offloaded with ESP - RPC"=disabled "Exchange 2016 HTTPS Reencrypted with ESP - RPC"=inService "Intranet Services HTTP Redirect"=redirect "Exchange 2010 HTTPS Offloaded with ESP - OWA"=disabled "Exchange 2016 HTTPS Offloaded - PowerShell"=inService "Servicedesk Change Password"=inService "Helpdesk"=inService "Exchange 2016 HTTPS Reencrypted with ESP - MAPI"=inService "Intranet Services"=inService "Exchange 2016 HTTPS Offloaded - EWS"=inService "Exchange 2016 HTTPS Offloaded"=inService "Exchange 2010 HTTPS Offloaded with ESP - EWS"=disabled "Exchange 2010 HTTPS Offloaded with ESP - ActiveSync"=disabled "Exchange 2016 HTTPS Offloaded - ActiveSync"=inService "Exchange HTTP Redirect"=redirect "Servicedesk"=inService "Exchange 2010 HTTPS Offloaded with ESP - ECP"=disabled "Servicedesk Extern"=inService "Exchange 2016 HTTPS Reencrypted with ESP - PowerShell"=inService "Exchange 2016 HTTPS Reencrypted with ESP - OAB"=inService "Exchange 2010 HTTPS Offloaded with ESP - PowerShell"=disabled "Exchange 2016 HTTPS Offloaded - HTTP Redirect"=redirect "Exchange 2016 HTTPS Reencrypted with ESP - ActiveSync"=inService "Exchange 2016 HTTPS Reencrypted with ESP - HTTP Redirect"=redirect "Servicedesk Authentication Proxy"=errormsg "Exchange 2010 HTTPS Offloaded with ESP - Autodiscover"=disabled "Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy"=disabled "Exchange 2016 HTTPS Offloaded - Autodiscover"=inService "Exchange 2016 HTTPS Reencrypted with ESP - Authentication Proxy"=errormsg "Exchange"=disabled "Exchange 2016 HTTPS Offloaded - RPC"=inService "Exchange 2016 HTTPS Offloaded - ECP"=inService "Exchange 2016 HTTPS Offloaded - MAPI"=inService 
RS on VS State Intranet Services:​443 (0)​: 

RS on VS State Exchange:​443 (0)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - Authentication Proxy:​443 (0)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - ActiveSync:​443 (1)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - Autodiscover:​443 (1)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - ECP:​443 (2)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - EWS:​443 (1)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - OAB:​443 (1)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - OWA:​443 (1)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - PowerShell:​443 (0)​: 

RS on VS State Exchange 2010 HTTPS Offloaded with ESP - RPC:​443 (0)​: 

RS on VS State Exchange HTTP Redirect:​80 (0)​: 

RS on VS State Intranet Services HTTP Redirect:​80 (0)​: 

RS on VS State Servicedesk:​443 (0)​: 

RS on VS State Servicedesk HTTP Redirect:​80 (0)​: 

RS on VS State Servicedesk Intern:​443 (1)​: 

RS on VS State Servicedesk Extern:​443 (1)​: 

RS on VS State Servicedesk Authentication Proxy:​443 (0)​: 

RS on VS State Helpdesk:​443 (1)​: 

RS on VS State Servicedesk Change Password:​443 (1)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - HTTP Redirect:​80 (0)​: 

RS on VS State Exchange 2016 HTTPS Offloaded:​443 (0)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - ActiveSync:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - Autodiscover:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - ECP:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - EWS:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - MAPI:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - OWA:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - PowerShell:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Offloaded - RPC:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP:​443 (0)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - Authentication Proxy:​443 (0)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - ActiveSync:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - Autodiscover:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - ECP:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - EWS:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - MAPI:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - OAB:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - OWA:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - PowerShell:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - RPC:​443 (2)​: 

RS on VS State Exchange 2016 HTTPS Reencrypted with ESP - HTTP Redirect:​80 (0)​:

And this is the check result of the same check executed via console:

OK: LoadBalancer: ST-KEMP01-RZ *Master* Uptime: 56 days, 01:34:07.86 Load: 0.15,0.20,0.22
Real Server (5):

Virtual Services (43):
| 'Load-1'=0.15;;;; 'Load-5'=0.20;;;; 'Load-15'=0.22;;;; 'ScriptRunTime'=536ms;;;;

I hope this wall of text helps :)

icinga-migration commented 8 years ago

Updated by tgelf on 2016-09-06 14:44:50 +00:00

I see... so your plugin accepts only a single parameter for -i. The following:

"a b","a c"x"a d"

is the same as:

"a b,a cxad"

This is a shell thing, Icinga does nothing special here. So, to get this working you should set all of those into a single string field, separated by comma:

Exchange 2016 HTTPS Offloaded - OAB,Exchange 2010 HTTPS Offloaded with ESP - ECP,Exc...

Then it should work fine. However, this is the opposite of what you asked for in your initial request, isn't it?

icinga-migration commented 8 years ago

Updated by log1c on 2016-09-06 15:02:15 +00:00

Ok. That comma-seperated string without the quotation marks works. Thanks a lot! I think I never would have considered this easy solution.

And the problem with the multiple arguemnts for nrpe_argument is solved by converting the field to the Array-Type, just tried it.

Thanks a lot!!

icinga-migration commented 8 years ago

Updated by tgelf on 2016-09-06 15:04:01 +00:00

Glad to hear that!