[icinga-users] Separate services or separate http_vhosts?

Gerald Vogt vogt at spamcop.net
Fri Jan 27 08:26:24 CET 2017


Neither one is correct. http_vhost of CheckCommand http is not an array 
but the virtual host to be sent:

https://docs.icinga.com/icinga2/latest/doc/module/icinga2/chapter/plugin-check-commands#plugin-check-command-http

The CheckCommand http makes a single check. It doesn't do multiple 
checks taken from an array.

What you probably want is to check a host for multiple vhosts hosted on 
that host. Thus something like this:

apply Service for (http_vhost => config in host.vars.http_vhosts) {
   import "generic-service"

   check_command = "http"

   vars += config
}

Which I think should be it the default services.conf...

Then you configure your host to check for vhosts like this:

object Host "www" {
   import ...

   address = ...
   address6 = ...

   vars.http_vhosts["main"] = {
     http_uri = "/"
   }
   vars.http_vhosts["search"] = {
     http_uri = "/search?pattern=foobar"
   }
}

Then the apply Service rule will create two services main and search and 
checks them individually...

See

https://docs.icinga.com/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2-first-steps

where it's explained in more detail for the disk check but works the 
same for http.

-Gerald

On 21/01/2017 22:25, Stephane Bortzmeyer wrote:
> I'm still overwhelmed by the amount of possibilities in Icinga2
> configuration language.
>
> I want to monitor two things on the same HTTP vhost, the main page and
> the search engine. Should I use two http_vhosts in the same service:
>
> apply Service "web" {
>
>   check_command = "http"
>
>   vars.http_vhosts["main"] = {
>     http_uri = "/"
>   }
>
>   vars.http_vhosts["search"] = {
>     http_uri = "/search?pattern=foobar"
>   }
>
>   assign where (host.address || host.address6) && host.vars.web == 1
>
>  }
>
> Or two services:
>
> apply Service "web-main" {
>
>   check_command = "http"
>
>   vars.http_vhosts["main"] = {
>     http_uri = "/"
>   }
>
>   assign where (host.address || host.address6) && host.vars.web == 1
>
> }
>
> apply Service "web-search" {
>
>   check_command = "http"
>
>   vars.http_vhosts["search"] = {
>     http_uri = "/search?pattern=foobar"
>   }
>
>   assign where (host.address || host.address6) && host.vars.web == 1
>
>  }
>
> What are the consequences of this choice? Is there a recommended way?
> It is not clear for me from the documentation.
> _______________________________________________
> icinga-users mailing list
> icinga-users at lists.icinga.org
> https://lists.icinga.org/mailman/listinfo/icinga-users
>



More information about the icinga-users mailing list