Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev.icinga.com #10528] Documentation example in "Access Object Attributes at Runtime" doesn't work correctly #3594

Closed
icinga-migration opened this issue Nov 4, 2015 · 6 comments
Labels
area/documentation End-user or developer help bug Something isn't working
Milestone

Comments

@icinga-migration
Copy link

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

Created by mwaldmueller on 2015-11-04 09:36:21 +00:00

Assignee: mwaldmueller
Status: Resolved (closed on 2015-11-25 15:49:13 +00:00)
Target Version: 2.4.1
Last Update: 2015-11-26 08:58:31 +00:00 (in Redmine)

Icinga Version: 2.3.11
Backport?: Already backported
Include in Changelog: 1

The following example doesn't work correctly:

object Host "cluster-host-01" {
  check_command = "dummy"
  vars.dummy_state = 2
  vars.dummy_text = "This host is down."
}

object Host "cluster-host-02" {
  check_command = "dummy"
  vars.dummy_state = 0
  vars.dummy_text = "This host is up."
}

object Host "cluster" {
  check_command = "dummy"
  vars.cluster_nodes = [ "cluster-host-01", "cluster-host-02" ]

  vars.dummy_state = {{
    var up_count = 0
    var down_count = 0
    var cluster_nodes = macro("$cluster_nodes$")

    for (node in cluster_nodes) {
      if (get_host(node).state > 0) {
        down_count += 1
      } else {
        up_count += 1
      }
    }

    if (up_count >= down_count) {
      return 0 //same up as down -> UP
    } else {
      return 1 //something is broken
    }
  }}

  vars.dummy_text = {{
    var output = "Cluster hosts:\n"
    var cluster_nodes = macro("$cluster_nodes$")

    for (node in cluster_nodes) {
      output += node + ": " + get_host(node).last_check_result.output + "\n"
    }

    return output
  }}
}

The problem ist that returncode "1" (= WARNING) in case of a broken state for a host is interpreted as "UP", so you have to change the returncode to "2" (= DOWN).

Attachments

Changesets

2015-11-25 15:48:40 +00:00 by mwaldmueller 7ecc6f7

Documentation: Fix error in Access Object Attributes at Runtime example

fixes #10528

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>

2015-11-25 15:49:33 +00:00 by mwaldmueller f79b073

Documentation: Fix error in Access Object Attributes at Runtime example

fixes #10528

Signed-off-by: Michael Friedrich <michael.friedrich@netways.de>

2015-11-26 09:35:24 +00:00 by mfriedrich ef0e03f

Update AUTHORS

refs #10528

2015-11-26 09:35:41 +00:00 by mfriedrich c983fde

Update AUTHORS

refs #10528
@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-04 09:59:42 +00:00

  • Status changed from New to Feedback
  • Assigned to set to mwaldmueller

Can you please provide a patch? Thank you.

@icinga-migration
Copy link
Author

Updated by mwaldmueller on 2015-11-04 10:54:39 +00:00

  • File added 0001-Fixed-an-error-in-Access-Object-Attributes-at-Runtim.patch

Done, find the patch attached

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-25 15:48:24 +00:00

  • Status changed from Feedback to Assigned
  • Target Version set to 2.5.0

@icinga-migration
Copy link
Author

Updated by mwaldmueller on 2015-11-25 15:49:13 +00:00

  • Status changed from Assigned to Resolved
  • Done % changed from 0 to 100

Applied in changeset 7ecc6f7.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-25 15:49:49 +00:00

  • Target Version changed from 2.5.0 to 2.4.1
  • Backport? changed from TBD to Yes

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-11-26 08:58:31 +00:00

  • Subject changed from Example in Access Object Attributes at Runtime doesn't work correctly to Documentation example in "Access Object Attributes at Runtime" doesn't work correctly

@icinga-migration icinga-migration added bug Something isn't working area/documentation End-user or developer help labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.4.1 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation End-user or developer help bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant