How to apply service checks for two satellite

Hi,

How can i apply service checks for two satellite?
under zone.d folder i have satellite-bw and satellite-eu

in the satellite-mu folder i have service.conf with the service checks below.
checks is running for only one satellite-bw.

apply Service "ping4" {
  check_command = "ping4"
  command_endpoint = host.vars.client_endpoint
  vars.ping_cpl = 50
  vars.ping_crta = 600
  vars.ping_wpl = 30
  vars.ping_wrta = 400
  assign where host.zone == "satellite-bw" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

apply Service "hostalive" {
  check_command = "hostalive"
  command_endpoint = host.vars.client_endpoint
  assign where host.zone == "satellite-bw" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

apply Service "users" {
  import "generic-service"
  check_command = "users"
  vars.users_wgreater = "2"
  vars.users_cgreater = "3"
  command_endpoint = host.vars.client_endpoint
  assign where host.zone == "satellite-bw" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

Thanks in advance

Add the line to the check definition

this what i did i got
critical/config: Error: An object with type ‘Service’ and name ‘app.example.com!ssh’ already exists (in /etc/icinga2/zones.d/satellite-eu/service_agent.conf:

The content of that file is?

This is the content:

apply Service "ping4" {
  check_command = "ping4"
  command_endpoint = host.vars.client_endpoint
  vars.ping_cpl = 50
  vars.ping_crta = 600
  vars.ping_wpl = 30
  vars.ping_wrta = 400
  assign where host.zone == "satellite-eu" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

apply Service "hostalive" {
  check_command = "hostalive"
  command_endpoint = host.vars.client_endpoint
  assign where host.zone == "satellite-eu" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

apply Service "users" {
  import "generic-service"
  check_command = "users"
  vars.users_wgreater = "2"
  vars.users_cgreater = "3"
  command_endpoint = host.vars.client_endpoint
  assign where host.zone == "satellite-eu" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

apply Service "procs" {
  import "generic-service"
  check_command = "procs"
  command_endpoint = host.vars.client_endpoint
  #command_endpoint = "vpseu01.lumic.co.bw"
  assign where host.zone == "satellite-eu" && host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

apply Service "ssh" {
  import "generic-service"
  check_command = "ssh"
  command_endpoint = "home.micinthe.com"
  //command_endpoint = host.vars.client_endpoint
  assign where host.vars.client_endpoint
  assign where (host.address || host.address6) && host.vars.os == "Linux"
}

apply Service "disk" {
  check_command = "disk"
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.client_endpoint
  vars.disk_wfree = "10%"
  vars.disk_cfree = "5%"
  assign where host.zone == "satellite-eu" && host.vars.client_endpoint
}

Ok, so you have it already and the real question is that you want to combine two service apply rules from each zone into one. Right?

Yes, This is exactly what i’m trying to do, but i can’t seems to find the solutions.

Move the apply rule into a global zone which is configured on both satellites, like global-templates.

apply Service "ping4" {
  check_command = "ping4"
  command_endpoint = host.vars.client_endpoint
  vars.ping_cpl = 50
  vars.ping_crta = 600
  vars.ping_wpl = 30
  vars.ping_wrta = 400
  assign where host.vars.client_endpoint
}

If you want to specifically add this to specific zones, you can extend the assign where rule to

  assign where (host.zone == “satellite-eu” || host.zone == “satellite-bw”) && host.vars.client_endpoint

Cheers,
Michael

1 Like