On 30/08/16 22:11, Lance Reed wrote:
I am in the process of attempting to setup EventCommand / Event
Handlers in Icinga2.

So far the documentation I am finding so far is spotty or confusing.

One complication is that we use applys for all of our checks vs service objects/

E.G.

apply Service "check_some_service" to Host {
      import "generic-service"
  display_name = "some service"
  assign where host.vars.puppet_role == "foo" || host.vars.puppet_role
== "bar" || match("baz*", host.name)
  ignore where host.name == "localhost"
  check_command = "by_ssh2"
  vars.by_ssh_command = "/usr/lib64/nagios/plugins/check_http -H
$host$ -p $port$ -u $uri$"
  vars.host = "localhost"
  vars.port = "58140"
  vars.uri = "http://localhost:59140/command?type=ping";
  event_command = "restart-some-event"
}

"apply Service" is just another way to define service objects. It loops through all matches and sets up a new service object for each. You'll see the results in the running configuration with "icinga2 object list" CLI.

So basically the "apply Service" is identical to many "object Service" definitions, if you would write down the "object Service" for each match from the "apply Service".

You can set pretty much any variable you want including event_command in either "object Service" or "apply Service".

check_some_service.conf


Can someone tell me if using "apply Service" will work with the
Icinga2 code when doing EventCommands to restart services etc?

Thanks for any ideas to get this moving forward.

Set up a single service (i.e. "object Service") for any service you want. Test it to see that it's working. If it's working, convert the "object Service" into a "apply Service" block to apply the identical service to all hosts which require it.

Use CLI "icinga2 object list" to verify the result.

-Gerald
_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to