Disable automatic ping-check

Hello again folks,

I added some hosts through the director where I only want to check if they’re Email is blacklisted. These Hosts do not accept ICMP notifications hence why I can not make an ping-check to them. So I made a template for them where they should only do the Email-Check. Yet they also do a ping4-check and I couldn’t figure out how to turn that off.

What I tried so far was modifying the services.conf on my master:

apply Service "ping4" {
  import "generic-service"
  
  check_command = "ping4"
 
  ignore where host.vars.ping == "no"
  assign where host.address
}

Where I added the ignore line because it was recommended in this short article. I know it’s german sorry about that. Does anyone has another solution for this?

Some facts about my setup:

  • the Email hosts don’t run Icinga (only need the adress basically)
  • the Email-Template does not Import any other template
  • the Command for the Email-Check is self-defined (does not have a ping-check though :D)
  • as an extra I defined a Service-Set with only one service (the Email-Check) for these Hosts
  • working on a Debian

Do you have hostalive defined? Then you know where the ping is coming from.

One more thing now:

I’ve found this post here which is very similar to my problem. So I definitely tried this out. But I have another plugin having an issue with that - the mattermost plugin. This plugin needs the “generic-host” and “user” from the templates.conf so I included that conf too but I get a lot more errors then. Basically does the mattermost plugin need the entire templates conf. I’m not sure how or where I should replicate it in the director so that the plugin can find it.

I do not quite understand your statement. It’s not doing a hostalive check. It specifically states the ping4 check. And I do have it defined on the master for other hosts where I want to check more than just if they’re blacklisted. But it is not defined on the Email-Template, Email-Service-Set or in single services for the Email-Hosts.

Would you mind sharing the host definition of one of the email hosts? I think this would help us a lot figuring this out :slight_smile:

Best,
Daniel

This would be the hosts.conf from /var/lib/icinga2/api/zones/master/director:

object Host "Gudrun.xxx.net" {
    import "Email"

    address = "Gudrun.xxx.net"
    groups = [ "Email" ]
}

object Host "Gunnar.xxx.net" {
    import "Email"

    address = "Gunnar.xxx.net"
    groups = [ "Email" ]
}

object Host "Hadding.xxx.net" {
    import "Email"

    address = "Hadding.xxx.net"
    groups = [ "Email" ]
}

object Host "Hagbard.xxx.net" {
    import "Email"

    address = "Hagbard.xxx.net"
    groups = [ "Email" ]
}

The Email template would just be this:

template Host "Email" {
    check_command = "Email"
}
apply Service "ping4" {
  import "generic-service"

  check_command = "ping4"

  ignore where host.vars.ping == "no"
  assign where host.address
}

With this configuration, the Service ping4 would still be applied to your mail hosts. Your Host objects do not have the ping variable set to "no".

Below is some config which I think will do what you want.

First, define the ping4 service:

apply Service "ping4" {
  import "generic-service"
  check_command = "ping4"
  assign where host.address
  ignore where host.vars.ping == "no"
}

Or, perhaps more clearly, use a boolean instead of a string variable:

apply Service "ping4" {
  import "generic-service"
  check_command = "ping4"
  assign where host.address
  ignore where host.vars.noping
}

Let’s define 2 Hosts which set noping:

object Host "gudrun.example.net" {
  check_command = "Email"
  address = "gudrun.example.net"
  groups = [ "Email" ]
  vars.noping = true
}

object Host "gunnar.example.net" {
  check_command = "Email"
  address = "gudrun.example.net"
  groups = [ "Email" ]
  vars.noping = true
}

That config above is fine. But we could use a Host template to avoid repeating ourselves. Here is a Host template which contains the attributes common to those Hosts:

template Host "email-host" {
  check_command = "Email"
  groups = [ "Email" ]
  vars.noping = true
}

Our Host definitions can then import that template and omit those attributes:

object Host "gudrun.example.net" {
  import "email-host"
  address = "gudrun.example.net"
}
object Host "gunnar.example.net" {
  import "email-host"
  address = "gunnar.example.net"
}

One more thing: if the name of the Host object is the same as the address, we can save repeating ourselves there too by setting address to name:

object Host "gudrun.example.net" {
  import "email-host"
  address = name
}
object Host "gunnar.example.net" {
  import "email-host"
  address = name
}
2 Likes