Reverse TCP/HTTP service

Hello all,

im relative new to icinga2(working with it for about 3 days).
I am currently trying to check if the GUI of my switch is reacheable with https. It should only be recheable with https and not with http. Checking if the https version is reachable is relatively easy. But how do I alert as soon as the site is also reachable by http. I tried with the normal check_http but I have no clue how to “reverse” the check. So it only alerts if the connection goes UP. So Down=ok, UP=critical

apply Service "check_http" {
                import "basic-http"
		max_check_attempts = 5
		check_interval = 5m
		retry_interval = 60s
		check_command = "http"
		vars.http_ssl = false
        assign where host.vars.kategorie == "xxxx" && host.vars.type == "xxxx"

Then I tried just to check if the port is listening with check_tcp.
I saw that there is a “tcp_refuse” in the documentation but this only states the refused connection with OK but doesn’t change when the port is UP, so it is always UP

apply Service "Tcp_80"{
		import "basic-service"
		check_command = "tcp"
		vars.tcp_port = "80"
		vars.tcp_refuse = "ok"
        assign where host.vars.kategorie == "xxxx" && host.vars.type == "xxxx"

Help is much appreciated!

With negate you can invert a check result.

1 Like

Thank you for your fast response. I didn’t notice that there is a negate command.
Im still having trouble using this command. It says “the command to be negated”.
So I need to negate the check_tcp/check_http wit vars and without?
Unfortunately im not able to do it.
I tried to negate tcp, check_tcp but nothing seems to work.
What am I doing wrong here?

apply Service "Tcp_443"{
		import "basic-service"
		check_command = "tcp"
		vars.negate_command = "tcp"
		vars.tcp_port = "443"
        assign where host.vars.kategorie == "xxxx" && host.vars.type == "xxxx"