Check_http always returning 503 on Icinga web2 but returning 200 OK from command line with same param values

Hi Team,

I am trying to add a service monitor and my host and service configuration looks like this:
object Host “proof-review.acs.org-host” {
import “generic-host”

    address = "proof-review.acs.org"
    check_interval = "300"
    display_name = "proof-review.acs.org"
    vars = {
            os = "Windows"
    }

}
object Service “APRSHome-service” {
import “generic-service”

    check_command = "http"
    check_interval = "300"
    display_name = "proof-review-APRSHome"
    host_name = "proof-review.acs.org-host"
    vars["http_onredirect"] = "follow"
    //vars["http_port"] = "443"
    vars["http_sni"] = true
    vars["http_ssl"] = true
    //vars["http_string"] = "ACS"
    vars["http_uri"] = "https://proof-review.acs.org/aprs/APRSHome.html"

}

and it gives me this output on the Dashboard:
HTTP CRITICAL: HTTP/1.1 503 Service Unavailable - 879 bytes in 1.506 second response time

BUT, if run the check_http command directly, it gives me 200 OK

This is the check command I run:
./check_http -H proof-review.acs.org -u https://proof-review.acs.org/aprs/APRSHome.html -S -f follow --sni
And it gives me this output:
HTTP OK: HTTP/1.1 200 - 8995 bytes in 2.787 second response time |time=2.787258s;;;0.000000;10.000000 size=8995B;;;0

so, what I am doing wrong that it gives 503 on Dashboard??

1 Like

Hi, if you run the command directly, do you use the icinga user? Maybe there is a proxy between it, or a SSO .

I run the command directly by logging in as root to the Host Machine
root@icinga:/usr/lib/nagios/plugins# ./check_http -H proof-review.acs.org -u https://proof-review.acs.org/aprs/APRSHome.html -S -f follow --sni
HTTP OK: HTTP/1.1 200 - 8993 bytes in 3.111 second response time |time=3.111444s;;;0.000000;10.000000 size=8993B;;;0

You should always test it with the icingauser. Also keep in mind, that icinga will not load the full user environment of the user.

Thank you But could you please suggest what we need to do here so that Icinga can execute the command with 200. And, also why it is giving 503 even though we can access the URL publicly?

Maybe the command is run with the -I (uppercase i) switch instead of the -H switch. See the difference:

# /usr/lib/monitoring-plugins/check_http -H proof-review.acs.org -u https://proof-review.acs.org/aprs/APRSHome.html -S -f follow --sni
HTTP OK: HTTP/1.1 200 - 8995 bytes in 0,847 second response time |time=0,847040s;;;0,000000;10,000000 size=8995B;;;0
# /usr/lib/monitoring-plugins/check_http -I proof-review.acs.org -u https://proof-review.acs.org/aprs/APRSHome.html -S -f follow --sni
HTTP CRITICAL: HTTP/1.1 503 Service Unavailable - 875 bytes in 0,050 second response time |time=0,049894s;;;0,000000;10,000000 size=875B;;;0

I usually handle it adding vars.http_vhost = "$host.name$".

Kind regards,
Bernd

2 Likes

Thank you very much Bernd. It fixed the problem for me.

2 Likes

Thanks for your feedback. I’m glad I could help you :slight_smile:

Yes, I would also want to understand though when to use “-I” and and when to use “-H”?

It depends on the webserver’s setup. For example, a web hoster (Strato, Netcup, …) serves many different websites on the same host (same IP address).
If you look up the IP address of the web site you’re using, you’ll get 45.60.80.135. Just put this in the web browser and you receive a resolving error page, since the web server doesn’t know which site you wanna access. The same happens when using check_http with just the -I parameter.

So every time the webserver needs to know which website (vhost) you’re requesting, you have to specify via the -H flag.

1 Like