0

What is best practice for configuring multiple HTTP checks for a host?

I know there is that "apply" method:

apply Service "http" for (http_vhost => config in host.vars.vhosts) {
    ...
}

But i do also need the "http_uri" value?!

How to do this via normal config files AND how to do this via the Director? Where and how i have to modify a template to get multiple HTTP checks linked to a specific host?

1 Answers1

0

I don't use the director, but I can tell you how I do this in normal code. Basically I'd create some dict / list, as you said (at various scopes). There you have to put variables there - those ones you want to change (so for example URL).

So you define a variable with your data. It can be under host, or you can create it in the global scope.

globals.http_urls = [ "/uril1", "/url2" ]

or

object Host "testhost" {
    host.address = 123.123.123.123
    vars.http_urls = [ "/url1", "/url2" ]
} 

then you can iterate over that variable

apply Service "http-url" for (url in globals.http_url) {
    command = http

    # ... other http check variables ...

    vars.http_url = url

    # ... other variables ...

    assign where host.name == "testhost"
}

you can also iterate over the dictionary, it works like that:

globals.testdict = {
    "server1" : "testdict",
    "server2" : "testweb",
    etc..
}

just use key => value format in for definition

apply Service "http-url" for (server => url in globals.testdict) {
    command = http
    display_name = "http check " + server

    vars.http_url = url
    .. etc

    assign where host.name == testserver
}
pershing
  • 46
  • 2