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 #12928] service cluster checking in director #496

Closed
icinga-migration opened this issue Oct 14, 2016 · 2 comments
Labels

Comments

@icinga-migration
Copy link
Member

@icinga-migration icinga-migration commented Oct 14, 2016

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

Created by swizzly on 2016-10-14 14:46:24 +00:00

Assignee: (none)
Status: Resolved (closed on 2016-10-14 19:29:50 +00:00)
Target Version: (none)
Last Update: 2016-10-17 14:35:20 +00:00 (in Redmine)


Hi

Is it possible to do something like this: http://docs.icinga.org/icinga2/snapshot/search?q=cluster\#!/icinga2/snapshot/doc/module/icinga2/chapter/advanced-topics?highlight-search=cluster#access-object-attributes-at-runtime in Director? I mean I would like to have the code that checks the Cluster health inside Director, and don't want to bother writing external config files for Icinga2.

cheers,
Zoltan

Attachments

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Oct 14, 2016

Updated by tgelf on 2016-10-14 19:29:50 +00:00

  • File added 01_clustercheck_command.png
  • File added 02_clustercheck_arg_state.png
  • File added 03_clustercheck_arg_text.png
  • File added 04_clustercheck_datafield.png
  • File added 05_clustercheck_servicetemplate_field.png
  • File added 06__clustercheck_service_definition.png
  • File added 07_clustercheck_status.png
  • Status changed from New to Resolved

Hi Zoltan,

this is absolutely possible. You are currently not allowed to write DSL to a Custom Variable, but it is perfectly legal to write them to a command argument. check_dummy is special as it's arguments are positional, but with an implicit skip_key (leaving the argument name empty) this is perfectly possible. Please find some screenshots attached, they show how it works (code is copied 1:1 from the link you provided):

01_clustercheck_command.png

02_clustercheck_arg_state.png

03_clustercheck_arg_text.png

04_clustercheck_datafield.png

05_clustercheck_servicetemplate_field.png

06__clustercheck_service_definition.png

07_clustercheck_status.png

Cheers,
Thomas

@icinga-migration

This comment has been minimized.

Copy link
Member Author

@icinga-migration icinga-migration commented Oct 17, 2016

Updated by swizzly on 2016-10-17 14:35:20 +00:00

Hi Thomas,

Many thanks, it works great.
I hope you don't mind, I adapted it to check clustered services on the same host. I share it for the case someone else would also need it.

The first argument of the command should look like this:

var up_count  = 0
var down_count = 0
var cluster_services = macro("$cluster_services$")
var hostname = macro("$host.name$")

for (service in cluster_services){
  if (get_service(hostname, service).state > 0){
    down_count += 1
  } else {
    up_count += 1
  }
}

if(up_count > down_count){
  return 0
} else {
  return 2
}

The second parameter should be changed to this:

var output = "Cluster services:\n"
var cluster_services = macro("$cluster_services$")
var hostname=macro("$host.name$")

for (service in cluster_services) {
  output += service + ":" + get_service(hostname, service).last_check_result.output + "\n"
}
return output

And of course accordingly the data fields name should be changed to "cluster_services" too.

Many thanks,
Zoltan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.