Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.03k stars 577 forks source link

assign rule with wildcard on host.groups only works, if host is in one hostgroup #8654

Closed Foxeronie closed 3 years ago

Foxeronie commented 3 years ago

Hey,

a Service Apply Rule with a wildcard on host.groups doesn't seem to work, if the host is in more than one hostgroup.

This worked while the host was in one hostgroup:

apply Service "amavisd Process" {
    import "__process__ Process Template"
    import "_service_with_auto-acknowledge"

    assign where match("mail/amavis/*", host.groups)
    groups = [ "IT-Infa", "IT-Mailmaster" ]
    vars.procs_name = "/usr/sbin/amavisd"
    vars.procs_name_set = true
    vars.procs_range_critical = "1:64"
    zone = "worker"

    import DirectorOverrideTemplate
}

But now the host is in two hostgroups. The apply rule doesn't work anymore. One hostgroup is defined in the host object, the other one is a hostgroup object where the host is in the assign rule.

<1> => get_host("smtp-dmz-3.domain.de")
{
    __name = "smtp-dmz-3.domain.de"
    acknowledgement = 0.000000
    acknowledgement_expiry = 0.000000
    acknowledgement_last_change = 0.000000
    action_url = ""
    active = true
    address = "192.168.4.171"
    address6 = ""
    check_attempt = 1.000000
    check_command = "icmp"
    check_interval = 60.000000
    check_period = ""
    check_timeout = null
    command_endpoint = ""
    display_name = "smtp-dmz-3"
    downtime_depth = 0.000000
    enable_active_checks = true
    enable_event_handler = true
    enable_flapping = false
    enable_notifications = true
    enable_passive_checks = true
    enable_perfdata = true
    event_command = ""
    extensions = {
        DbObject = {
            type = "Object"
        }
    }
    flapping = false
    flapping_buffer = 0.000000
    flapping_current = 0.000000
    flapping_index = 2.000000
    flapping_last_change = 0.000000
    flapping_threshold = 0.000000
    flapping_threshold_high = 30.000000
    flapping_threshold_low = 25.000000
    force_next_check = false
    force_next_notification = false
    groups = [ "mail/amavis/dmz", "Mailserver" ]
    ha_mode = 0.000000
    handled = false
    icon_image = "/img/xen-linux.png"
    icon_image_alt = "xen-linux"
    last_check = 1614764967.562602
    last_check_result = {
        active = true
        check_source = "icinga-worker10.domain.de"
        command = [ "/usr/lib/nagios/plugins/check_icmp", "-H", "192.168.4.171", "-c", "900,80%", "-w", "600,60%" ]
        execution_end = 1614764967.562576
        execution_start = 1614764967.540317
        exit_status = 0.000000
        output = "OK - 192.168.4.171: rta 0.624ms, lost 0%"
        performance_data = [ "rta=0.624ms;600.000;900.000;0;", "pl=0%;60;80;;", "rtmax=1.039ms;;;;", "rtmin=0.485ms;;;;" ]
        schedule_end = 1614764967.562602
        schedule_start = 1614764967.540000
        state = 0.000000
        ttl = 0.000000
        type = "CheckResult"
        vars_after = {
            attempt = 1.000000
            reachable = true
            state = 0.000000
            state_type = 1.000000
        }
        vars_before = {
            attempt = 1.000000
            reachable = true
            state = 0.000000
            state_type = 1.000000
        }
    }
    last_check_started = 1614764967.540226
    last_hard_state = 0.000000
    last_hard_state_change = 1608660456.464689
    last_hard_state_raw = 0.000000
    last_hard_states_raw = 0.000000
    last_reachable = true
    last_soft_states_raw = 2.000000
    last_state = 0.000000
    last_state_change = 1608660456.464689
    last_state_down = 1608660399.390628
    last_state_raw = 0.000000
    last_state_type = 1.000000
    last_state_unreachable = 0.000000
    last_state_up = 1614764967.564172
    max_check_attempts = 10.000000
    name = "smtp-dmz-3.domain.de"
    next_check = 1614765026.564199
    next_update = 1614765086.609351
    notes = ""
    notes_url = "https://confluence.domain.de/display/ITDOCS/E-Mail-Services+--+Operations"
    original_attributes = null
    package = "director"
    pause_called = false
    paused = false
    previous_state_change = 1608660456.464689
    problem = false
    resume_called = true
    retry_interval = 60.000000
    severity = 0.000000
    source_location = {
        first_column = 1.000000
        first_line = 88597.000000
        last_column = 32.000000
        last_line = 88597.000000
        path = "/var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/hosts.conf"
    }
    start_called = true
    state = 0.000000
    state_loaded = true
    state_raw = 0.000000
    state_type = 1.000000
    stop_called = false
    suppressed_notifications = 0.000000
    templates = [ "smtp-dmz-3.domain.de", "_agent", "_interval_10x1min" ]
    type = "Host"
    vars = {
        has_agent = true
        has_multipath = false
        has_nrpe = true
        icmp_upper_critical = "900,80%"
        icmp_upper_warning = "600,60%"
        impact = 100.000000
        location = "smtp-xen-02"
        manufacturer = "XenServer"
        model = "virtualmachine"
        monitoring_class = "standard"
        operating_system = "linux"
        parent_switch = "unknown"
        support_group = [ "leitstand" ]
    }
    version = 0.000000
    volatile = false
    zone = "worker"
}

Your Environment

icinga2 - The Icinga 2 network monitoring daemon (version: r2.12.3-1)

Copyright (c) 2012-2021 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
  Platform: Ubuntu
  Platform version: 20.04.2 LTS (Focal Fossa)
  Kernel: Linux
  Kernel version: 5.4.0-65-generic
  Architecture: x86_64

Build information:
  Compiler: GNU 9.3.0
  Build host: runner-hh8q3bz2-project-298-concurrent-0
  OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020

Application information:

General paths:
  Config directory: /etc/icinga2
  Data directory: /var/lib/icinga2
  Log directory: /var/log/icinga2
  Cache directory: /var/cache/icinga2
  Spool directory: /var/spool/icinga2
  Run directory: /run/icinga2

Old paths (deprecated):
  Installation root: /usr
  Sysconf directory: /etc
  Run directory (base): /run
  Local state directory: /var

Internal paths:
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Modified attributes path: /var/lib/icinga2/modified-attributes.conf
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /run/icinga2/icinga2.pid
Disabled features: command compatlog debuglog elasticsearch gelf icingadb influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker graphite ido-mysql mainlog notification
Icinga Web 2 Version
    2.8.2
Git commit
    c2efbbdafc8b8912a92fc1bf3bd79f8d39b4c2dc 

businessprocess | 2.3.0
director | master
generictts | 2.0.0
incubator | 0.6.0
ipl | v0.5.0
monitoring | 2.8.2
reactbundle | 0.8.0
[2021-03-03 10:45:47 +0100] information/cli: Icinga application loader (version: r2.12.3-1)
[2021-03-03 10:45:47 +0100] information/cli: Loading configuration file(s).
[2021-03-03 10:45:48 +0100] information/ConfigItem: Committing config item(s).
[2021-03-03 10:45:48 +0100] information/ApiListener: My API identity: icinga-master10.domain.de
[2021-03-03 10:45:58 +0100] information/WorkQueue: #4 (DaemonUtility::LoadConfigFiles) items: 0, rate: 72/s (4320/min 4320/5min 4320/15min);
[2021-03-03 10:45:58 +0100] information/WorkQueue: #5 (GraphiteWriter, graphite) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2021-03-03 10:45:58 +0100] information/WorkQueue: #7 (ApiListener, RelayQueue) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2021-03-03 10:45:58 +0100] information/WorkQueue: #8 (ApiListener, SyncQueue) items: 0, rate:  0/s (0/min 0/5min 0/15min);
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Event Log' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 1953:1-1953:29) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Event Log' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 1964:1-1964:29) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Event Log' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 2008:1-2008:29) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Event Log' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 2019:1-2019:29) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Power8 Temperatures' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 2338:1-2338:39) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Power8 Temperatures' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 2349:1-2349:39) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Power8 Temperatures' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 2404:1-2404:39) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'HMC Power8 Temperatures' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 2415:1-2415:39) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'Memory and Swap Usage' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 7396:1-7396:37) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'amavisd Process' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 7996:1-7996:31) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'vmtoolsd Process' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 9015:1-9015:32) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'System Load' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 9184:1-9184:27) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'PuppetDB Node' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 9690:1-9690:29) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] warning/ApplyRule: Apply rule 'TCP Port 3128' (in /var/lib/icinga2/api/packages/director/97e4f54b-69df-47d1-9376-780803a4be29/zones.d/worker/service_apply.conf: 11590:1-11590:29) for type 'Service' does not match anywhere!
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 NotificationComponent.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 6116 Hosts.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 3285 Downtimes.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 GraphiteWriter.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 6 NotificationCommands.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 FileLogger.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 2623 Comments.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 21726 Notifications.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 IcingaApplication.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 423 HostGroups.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 56375 Dependencies.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 CheckerComponent.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 3229 Zones.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 3231 Endpoints.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 IdoMysqlConnection.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 14 ApiUsers.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 1 ApiListener.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 131 CheckCommands.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 4 TimePeriods.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 2 UserGroups.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 94 Users.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 80024 Services.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 43 ServiceGroups.
[2021-03-03 10:46:15 +0100] information/ConfigItem: Instantiated 39 ScheduledDowntimes.
[2021-03-03 10:46:15 +0100] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2021-03-03 10:46:15 +0100] information/cli: Finished validating the configuration file(s).
object Endpoint "icinga-master10.domain.de" {
}

object Endpoint "icinga-master11.domain.de" {
  host = "192.168.194.116"
  log_duration = 0s
}

object Endpoint "icinga-monitor10.domain.de" {
  host = "192.168.64.241"
  log_duration = 0s
}

object Endpoint "icinga-monitor11.domain.de" {
  host = "192.168.64.242"
  log_duration = 0s
}

object Endpoint "icinga-monitor12.domain.de" {
  host = "192.168.64.243"
  log_duration = 0s
}

object Endpoint "icinga-monitor13.domain.de" {
  host = "192.168.64.244"
  log_duration = 0s
}

object Endpoint "icinga-worker10.domain.de" {
  host = "192.168.194.118"
  log_duration = 0s
}

object Endpoint "icinga-worker11.domain.de" {
  host = "192.168.194.119"
  log_duration = 0s
}

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

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

object Zone "master" {
  endpoints = [ "icinga-master10.domain.de", "icinga-master11.domain.de", ]
}

object Zone "monitor-afs" {
  endpoints = [ "icinga-monitor12.domain.de", "icinga-monitor13.domain.de", ]
  parent = "master"
}

object Zone "monitor-general" {
  endpoints = [ "icinga-monitor10.domain.de", "icinga-monitor11.domain.de", ]
  parent = "master"
}

object Zone "worker" {
  endpoints = [ "icinga-worker10.domain.de", "icinga-worker11.domain.de", ]
  parent = "master"
}

Best regards, Patrick

Al2Klimov commented 3 years ago

Hello @Foxeronie and thank you for reporting!

Have you tried assign where match("mail/amavis/*", host.groups, MatchAny)?

Best, AK

Foxeronie commented 3 years ago

Hi AK,

thanks for your quick answer. Since this Apply Rule was created with Icinga Director, I'm not sure if I can set this parameter. But I will try this with a self created config for now and reply again.

Best regards, Patrick

Foxeronie commented 3 years ago

Hey AK,

the MatchAny parameter worked fine. I opened a feature request at director module.

Best regards, Patrick