Trying to monitor a websites response

Hi there,

I am tryinto to monitor a website , external to the company , using the check_http

object CheckCommand “check_http” {
import “plugin-check-command”
command = [ PluginDir + “/check_http”

    arguments = {
    "-H" = "$http_vhost$"
    "-I" = "$http_address"
    "-u" = "$http_uri$"
    "-p" = "$http_port$"
    "-S" = {
        set_if = "$http_ssl$"
    }
    "-w" = "$http_warn_time$"
    "-c" = "$http_critical_time$"

> }]

    vars.http_address = "$address$"
    vars.http_ssl = false

}

and then i have define the host

object Host VPN_HTTP {
 import "generic-host"
 address = "196.29.192.18"
 vars.os = "Checkpoint"
 vars.http_vhosts["http"] = {
  http_uri = "/"
}
  vars.http_ssl = "1"
  vars.http_warn_time = "5"
  vars.http_critical_time = "10"

  vars.notification["mail"] = {
   groups = [ "icingaadmins" ]
}
}

however , everytime i restart the service i get an error on command.conf

Nov 15 13:12:34 srvcheckmk icinga2[642]: /etc/icinga2/conf.d/commands.conf(199):  command =  [ PluginDir + "/check_http"
Nov 15 13:12:34 srvcheckmk icinga2[642]: /etc/icinga2/conf.d/commands.conf(200):
Nov 15 13:12:34 srvcheckmk icinga2[642]: /etc/icinga2/conf.d/commands.conf(201):         arguments = {
Nov 15 13:12:34 srvcheckmk icinga2[642]:                                                 ^^^^^^^^^
Nov 15 13:12:34 srvcheckmk icinga2[642]: /etc/icinga2/conf.d/commands.conf(202):  "-H" = "$http_vhost$"
Nov 15 13:12:34 srvcheckmk icinga2[642]: /etc/icinga2/conf.d/commands.conf(203):  "-I" = "$http_address"
Nov 15 13:12:34 srvcheckmk systemd[1]: icinga2.service: Main process exited, code=exited, status=1/FAILURE
Nov 15 13:12:34 srvcheckmk systemd[1]: Failed to start Icinga host/service/network monitoring system.

can someone explain me why will not go throuh?

Don’t specify your own check_http command. Just use the one from ITL.

https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#http

It’s very similar to your’s but it includes all the possible arguments and is proven and tested and checked for typos. :smile:

1 Like

Hi there,

I am tryinto to monitor a website , external to the company , using the
check_http

object CheckCommand “check_http” {

    import "plugin-check-command"
    command =  [ PluginDir + "/check_http"
    
    arguments = {
    "-H" = "$http_vhost$"
    "-I" = "$http_address"

Try adding a $ at the end of that :slight_smile:

    "-u" = "$http_uri$"
    "-p" = "$http_port$"
    "-S" = {
    
        set_if = "$http_ssl$"
    
    }
    "-w" = "$http_warn_time$"
    "-c" = "$http_critical_time$"

> }]

    vars.http_address = "$address$"
    vars.http_ssl = false

}

Regards,

Antony.

Ok,
so i have removed the check command definition.
now…
I have the host definition only left and it is showing on web interface but is it not fetching the http response , i think need to customize thet check_http parameters to connect to the desired web , where can i change that?
imagen

Just look up the macros you have to set in the CheckCommand definition or, even better, in the docs. You can set the macros in the service or in the host object - just be aware that they have a different priority when searching for actual values.

e.g.

vars.http_address = "www.example.com"
vars.http_vhost = "my.pretty-website.com"

similar to what you did in your initial post. Don’t go for the configuration example with dictionaries in the first place. You mixed it up in your example code. Add a single service and set everything as a var. custom var. Don’t use { }.

The apply for stuff with directories is cool and all but it could be a bit overwhelming when you’re new to Icinga.

All i want to do is to monitor a url. the command works fine. could you be more specific about which files do i need to modify…

root@srvcheckmk:/usr/lib/nagios/plugins# ./check_http 196.29.192.18 -u https://vvv.tttt.com/sslvpn/Login/Login -S
HTTP OK: HTTP/1.1 302 Found - 650 bytes in 0.712 second response time |time=0.711929s;;;0.000000 size=650B;;;0

thanks,

This is my current checkCommand

object CheckCommand "my_http" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_http" ]
  arguments = {
        "-I" = {
        value = "$my_http_address$"
        description = "IP address or name."
        required = true
        }
        "-u" = {
        value = "$my_https_url$"
        description= "URL to GET or POST (default: /)"
        }
}
 vars.my_http_address = "$address$"
}

but all i am getting is

Name or service not known
HTTP CRITICAL - Unable to open TCP socket

Your CheckCommand is missing the -S parameter.

Why you create again a http check? Use the one from ITL and set you variables right.

in my hosts i have dictionaries like this one:

  vars.http_vhosts["www.koebbes.de"] = {
    http_uri = "/"
    http_vhost = "www.koebbes.de"
    http_ssl = true
  }

and the service is simple like that

apply Service "http " for (http_vhost => config in host.vars.http_vhosts) {
  import "generic-service"
                                                                                                                                                                                                                   
  check_command = "http"
                                                                                                                                                                                                                   
  vars.http_extendedperfdata = true
                                                                                                                                                                                                                   
  vars += config
                                                                                                                                                                                                                   
  assign where host.vars.http_vhosts != ""
}

Works like a charm.

1 Like

What @Carsten said. Drop your my_http CheckCommand and just use the http Command that’s already provided by Icinga. You don’t have to include it and you won’t find it in /etc/icinga2 (but in /usr/share/icinga2....

That’s what I suggested initially but maybe I wasn’t clear enough in my wording.

@twidhalm you were clear i just didnt know how to do it…
so i am now using the provided check and the result is…

imagen

this is is my host object…

object Host “FFFFF_VPN_1” {
import “generic-host”
check_command = “http”
vars.http_vhosts[“FFFF_VPN_1”] = {
http_vhost = “111.11.111.11”
http_uri = “vpn.domain.tld/sslvpn/Login/Login”
http_ssl = “true”
}
vars.http_warn_time = “5”
vars.http_critical_time = “10”

vars.notification[“mail”] = {
groups = [ “icingaadmins”, “projectman” ]
}
}

any suggestions

Ok. Please show us your corresponding Service definition.

And please show us the output of

curl https://vpn.domain.tld/sslvpn/Login/Login when run on your host. This looks a bit like your monitoring host is not able to connecto to the host you want to monitor.

Http_ssl is bolean not string and vhost should be the fqdn and not the ip

service definition

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

vars.http_extenderperfdata = true

  vars += config
  assign where host.vars.http_vhosts != ""
}

and the output of the curl command ist nothing. just empty

root@srvcheckmk:/etc/icinga2/conf.d# curl https://vpn.domain.tt/sslvpn/Login/Login

root@srvcheckmk:/etc/icinga2/conf.d#

are you sure that there has to be absolutely no command.conf reference for the checkcommand?? it is saying…

imagen

1 Like

ok, so now it is starting to work… just some details are left… here is the config…

apply Service "http" for (http_vhost => config in host.vars.http_vhosts) {
  import "generic-service"
  check_command = "http"
  vars += config
  assign where host.vars.http_vhosts != ""
}

and these two public internet faced ip addresses i want to monitor

object Host "vpn_2" {
  import "generic-host"
  address = "44.82.61.135"
  check_command = "http"
  vars.http_vhosts["vpn.fsgha.it/sslvpn/Login/Login"] = {
    http_uri = "/check/"
}
}


object Host "vpn_1" {
  import "generic-host"
  address = "126.27.142.88"
  check_command = "http"
  vars.http_vhosts["vpn.fsgha.it/sslvpn/Login/Login"] = {
    http_uri = "/check/"
}
}

so it monitoring okey the first link, but it just shows twice on icinga i dont know why

and the second link gives socket timeout, and it also appears twice

imagen

i have managed to resolved the duplicated entries…

would this object definition approach actually work?

object Host “vpn_fmwea” {
import “generic-host”
address = “166.29.152.18”
check_command = “http”
vars.http_vhosts[“vpn.fmwea.ito/sslvpn/Login/Login”] = {
http_uri = “/check/”
}
vars.http_vhosts[“vpn2.fmwea.ao/sslvpn/Login/Login”] = {
http_uri = “/check/”
}
}

how do i know that those specifc urls are being checked and most importantly , those url are using ssl and i havent set it anywhere…

imagen