How to override Icinga ITL »http« CheckCommand


(Tobias Wolf) #1

Salve,

I want »check_command = http« checks to return the content/body of the checked service.

  1. I’ve managed to get a PR merged here: https://github.com/monitoring-plugins/monitoring-plugins/pull/1560
  2. Last release was 2016
  3. I’ve build a PPA of monitoring-plugins and got that apt-mirrored locally
  4. Now, I want to add a parameter vars.http_showbody to the http command
  5. When I just add a CheckCommand with the same name »http«, then Icinga complains about the dupe and reefuses to validate the config

What now? I don’t want to use another CheckCommand name like »http_for_real« and change all our complicated configs.

So how can I override the ITL? Patch the file locally on disk and then again after each Icinga package upgrade? Do a dpkg-divert only for this?


(Tobias Wolf) #2

My attempt:

$ cat check-command-http.conf | grep -E -C3 "CheckCommand|showbody"  
object CheckCommand "http" {
        import "ipv4-or-ipv6"

        command = [ PluginDir + "/check_http" ]
--
                        description = "Print additional perfdata"
                }
                "-B" = {
                        set_if = "$http_showbody$"
                        description = "Print body below statusline"
                }
                "-f" = {
--
        vars.http_address = "$check_address$"
        vars.http_ssl = false
        vars.http_sni = false
        vars.http_showbody = false
        vars.http_linespan = false
        vars.http_invertregex = false
        vars.check_ipv4 = "$http_ipv4$"

(Carsten Köbke) #3

Hello Tobias,

you managed to write a PR for the plugin. So why not write an PR for the ITL command definition?
Until you PR gets merged, you can just edit the ITL command definition on your local server, but remember this will get overwritten by updates.

Regards,
Carsten


(Tobias Wolf) #4

So why not write an PR for the ITL command definition?

Because there is no release with my change on the horizon. The last release was 2016.

Until you PR gets merged, you can just edit the ITL command definition on your local server, but remember this will get overwritten by updates.

So I cannot override existing ITL commands?

I’m gonna hackfix this for the time being, becase we need this now.


(Carsten Köbke) #5

You can not overwrite, but edit or give it a new name.


#6

I would recommend to create a new command with a new name (e.g. my-http) which imports the existing command “http” and only add the additional parameter. All the rest is then always imported from the ITL “http” command, so you get every change that is made there in the future also in your new command.


(Markus Frosch) #7

How about:

object CheckCommand "local/http" {
        import "http"

        arguments += {
                "-B" = {
                        set_if = "$http_showbody$"
                        description = "Print body below statusline"
                }
        }

        vars.http_showbody = false
}

(Tobias Wolf) #8

Yes, sounds good. I’ll go with that.

So "local/http" is just a normal string and I’ll have to do
s,check_command http,check_command local/http,?


(Markus Frosch) #9

Well you create a new command, importing the old, the name can contain most normal characters…