GithubHelp home page GithubHelp logo

Comments (3)

julianbrost avatar julianbrost commented on May 23, 2024

Which version are you using?

Also, in the middle code snippet, you are setting notification.sms.users within vars.curl_checks["pr01_check"], is that intended?

I think it would help if you'd also share more of the object definitions so that it's clear what's within an object/template/apply rule and what is imported where.

Commenting out that line in service template fixes my problems.

Having a look at the output of the following command for the affected service with and without the line commented out could also give some clues:

icinga2 object list -t Service -n 'affected-host-name!affected-service-name'

from icinga2.

yoshi314 avatar yoshi314 commented on May 23, 2024

I am running icinga2 2.14 , on Debian. Packages are from icinga's deb repository.

this is what is produced when i had that line enabled:

{
  "curl_credentials": "configurator:sekrit",
  "curl_critical": 7200,
  "curl_hostname": "server..com",
  "curl_port": 8080,
  "curl_request": "GET",
  "curl_url": "management/queue/monitoring/secondsSinceTheOldestMessageInQueue/ACTIVE",
  "curl_warning": 3600,
  "display_name": "Oldest message in w ACTIVE",
  "jira_notification_config": {
    "jira_project": "MU",
    "jira_template": "cmb_utrzymanie",
    "times": {
      "begin": 600
    },
    "users": [
      "jira_cmb"
    ]
  },
  "notification": {
    "jira": {
      "times": {
        "begin": 3600
      }
    },
    "mail": {
      "extra_groups": [
        "utrzymanie-cmb"
      ],
      "interval": 86400,
      "period": "workhours"
    }
  }
}

I only had the older dump that i formatted via jq.

And the vars section when it is disabled

  * vars
    % = modified in '/etc/icinga2/zones.d/global/service/check_curl_value.conf', lines 4:2-4:15
    * curl_credentials = "configurator:sekrit"
    * curl_critical = 7200
    * curl_hostname = "server..com"
    * curl_port = 8080
    * curl_request = "GET"
    * curl_url = "management/queue/monitoring/secondsSinceTheOldestMessageInQueue/ACTIVE"
    * curl_warning = 3600
    * display_name = "Oldest message in ACTIVE"
    * notification
      * sms
        * users = [ "cmb-sms", "dyzur_20_7" ]
      * users = [ "grczyz" ]

Also, in the middle code snippet, you are setting notification.sms.users within vars.curl_checks["pr01_check"], is that intended?

I think i was trying to narrow down what was going on, that was superfluous.

The relevant config is here

  vars.curl_checks["queue-oldest-msg-ACTIVE"] = {
    display_name = "Oldest message in ACTIVE"
    curl_credentials = "configurator:sekrit"
    curl_hostname = "server.com"
    curl_url = "management/queue/monitoring/secondsSinceTheOldestMessageInQueue/ACTIVE"
    curl_port = 8080
    curl_request = "GET"
    curl_critical = 7200
    curl_warning = 3600
    notification.users += [ "grczyz" ]
    notification.sms.users = [ "cmb-sms" , "dyzur_20_7" ]
  }

This is constructed via generic for loop

apply Service "curl_check" for (check_name => config in host.vars.curl_checks) {
        check_command = "check-curl-value"

        vars += config
        import "fix-display-name"  // this maps vars.display_name to display_name
        import "generic-service"
        assign where host.vars.curl_checks
}

And the imported template:

template Service "generic-service" {
  max_check_attempts = 5
  check_interval = 5m
  retry_interval = 90s
  check_period = "24x7"

// this causes problems, destroying existing service.vars.notification.* 
  //if (host.vars.all_services) {
  //  vars += host.vars.all_services
  //}

// import global host defaults, i added this as a workaround. previously i searched through vars imported in above section
  if (host.vars.all_services.notification.period) {
    check_period = host.vars.all_services.notification.period
  }
  if (host.vars.all_services.notification.interval) {
    check_interval = host.vars.all_services.notification.interval
  }
  if (host.vars.all_services.notification.check_attempts) {
    max_check_attemps = host.vars.all_services.notification.check_attempts
  }

  if (service.vars.check_period) { 
    check_period = service.vars.check_period
  }

  if (service.vars.check_interval) { 
    check_interval = service.vars.check_interval
  }

  if (service.vars.max_check_attempts) { 
    max_check_attempts = service.vars.max_check_attempts
  }
}

from icinga2.

julianbrost avatar julianbrost commented on May 23, 2024

vars += host.vars.all_services does something quite different.

To me it looks like you expect vars.all_services.notification.mail.extra_groups += [ "support-PR01" ] to be the same as

vars += {
  all_services = {
    notification = {
      mail = {
        extra_groups = [ "support-PR01" ]
      }
    }
  }
}

But the latter is more like this:

vars.all_services = {
  notification = {
    mail = {
      extra_groups = [ "support-PR01" ]
    }
  }
}

That is, += does not attempt to deep-merge any data structures. So with base and extra being dicts, base += extra takes all keys and values contained directly in extra and sets them in base (where set means replacing the value at a key if that was set before).

from icinga2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.