# Check\_http random socket timeout

**URL:** <https://community.icinga.com/t/check-http-random-socket-timeout/7926>\
**Category:** Service Monitoring\
**Tags:** check\_http, icinga2\
**Created:** [August 4, 2021, 10:14am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926 "2021-08-04T10:14:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![HExSM](https://community.icinga.com/letter_avatar_proxy/v4/letter/h/bbce88/32.png) [@HExSM](https://community.icinga.com/u/HExSM)\
**Post date:** [August 4, 2021, 10:14am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/1 "2021-08-04T10:14:26Z")

</div>

I monitor some websites with the check\_http plugin. This works quite well so far. However, I get a critical alarm at irregular intervals: `CRITICAL - Socket timeout after 10 seconds`.

I have looked at the access logs on the web server and cannot find any entries for the time when the alarm was triggered.

Therefore, I assume that there is already a problem on the monitoring server, which means that no request can be sent to the website.

How could I debug this?

Icinga is running on an Ubuntu 20.04 server in version v2.12.5-1. The configuration was done with the Icinga Director.

The service configuration looks like:

```auto
template Service "_default" {
    max_check_attempts = "3"
    check_interval = 1m
    retry_interval = 30s
    check_timeout = 30s
    enable_notifications = true
    enable_active_checks = true
    enable_passive_checks = true
    enable_event_handler = false
    enable_flapping = false
    enable_perfdata = true
}

template Service "http" {
    import "_default"

    check_command = "http"
    vars.http_critical_time = "5"
    vars.http_ignore_body = true
    vars.http_onredirect = "follow"
    vars.http_ssl = true
    vars.http_vhost = "$host.address$"
    vars.http_warn_time = "2"
}

```

Thank you in advance! 🙂

---

<div class="post-metadata">

**Author:** ![rsx](https://community.icinga.com/user_avatar/community.icinga.com/rsx/32/2094_2.png) [@rsx](https://community.icinga.com/u/rsx)\
**Post date:** [August 4, 2021, 10:29am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/2 "2021-08-04T10:29:41Z")

</div>

> [@HExSM](#):
>
> How could I debug this?

You can [enable debug log](https://icinga.com/docs/icinga-2/latest/doc/15-troubleshooting/#enable-debug-output) to get more details. And you can manually run the plugin with adding `--verbose`.

---

<div class="post-metadata">

**Author:** ![Pooh](https://community.icinga.com/letter_avatar_proxy/v4/letter/p/f05b48/32.png) [@Pooh](https://community.icinga.com/u/Pooh)\
**Post date:** [August 4, 2021, 10:38am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/3 "2021-08-04T10:38:25Z")

</div>

It would be useful to know a bit more about your Icinga network.

Do you have:

a) just a single Icinga server performing all monitoring checks?

b) a Master with one or more Agents?

c) a Master with one or more Satellites, and one or more Agents?

Finally, out of the above descriptions, which Icinga server is performing the  
http service check on your web server?

Thanks,

Antony.

---

<div class="post-metadata">

**Author:** ![HExSM](https://community.icinga.com/letter_avatar_proxy/v4/letter/h/bbce88/32.png) [@HExSM](https://community.icinga.com/u/HExSM)\
**Post date:** [August 4, 2021, 11:15am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/4 "2021-08-04T11:15:49Z")

</div>

I have 1 Icinga master which performans the monitoring checks for systems, where it’s not possible to install the Icinga Agent, like websites, printer, switches etc… On the servers (16) the Icinga Agent is running.

The http service check is running on the Icinga master.

Best regards  
Stefan

---

<div class="post-metadata">

**Author:** ![HExSM](https://community.icinga.com/letter_avatar_proxy/v4/letter/h/bbce88/32.png) [@HExSM](https://community.icinga.com/u/HExSM)\
**Post date:** [August 4, 2021, 11:16am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/5 "2021-08-04T11:16:41Z")

</div>

Thank you! I will try the debug log functionality. 🙂

Best regards  
Stefan

---

<div class="post-metadata">

**Author:** ![HExSM](https://community.icinga.com/letter_avatar_proxy/v4/letter/h/bbce88/32.png) [@HExSM](https://community.icinga.com/u/HExSM)\
**Post date:** [August 4, 2021, 1:17pm UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/6 "2021-08-04T13:17:02Z")

</div>

Here is an excerpt from the debug.log:

```auto
[2021-08-04 14:41:28 +0200] notice/Process: PID 584506 ('/usr/lib/nagios/plugins/check_http' '--no-body' '-H' 'www.mydomain.tld' '-I' 'www.mydomain.tld' '-S' '-c' '5' '-f' 'follow' '-w' '2') terminated with exit code 2
[2021-08-04 14:41:28 +0200] notice/Dependency: Dependency 'mydomain.tld!internet-connection' passed: Parent host '_internet-connection' matches state filter.
[2021-08-04 14:41:28 +0200] notice/Dependency: Dependency 'mydomain.tld!http!host' passed: Parent host 'mydomain.tld' matches state filter.
[2021-08-04 14:41:28 +0200] notice/Dependency: Dependency 'mydomain.tld!internet-connection' passed: Parent host '_internet-connection' matches state filter.
[2021-08-04 14:41:28 +0200] notice/Dependency: Dependency 'mydomain.tld!http!host' passed: Parent host 'mydomain.tld' matches state filter.
[2021-08-04 14:41:28 +0200] debug/Checkable: Update checkable 'mydomain.tld!http' with check interval '60' from last check time at 2021-08-04 14:41:28 +0200 (1.62808e+09) to next check time at 2021-08-04 14:41:56 +0200 (1.62808e+
09).
[2021-08-04 14:41:28 +0200] notice/ApiListener: Relaying 'event::SetNextCheck' message
[2021-08-04 14:41:28 +0200] notice/Checkable: State Change: Checkable 'mydomain.tld!http' soft state change from OK to CRITICAL detected.
[2021-08-04 14:41:28 +0200] notice/ApiListener: Relaying 'event::CheckResult' message

```

Unfortunately, that doesn’t help me either.

---

<div class="post-metadata">

**Author:** ![rsx](https://community.icinga.com/user_avatar/community.icinga.com/rsx/32/2094_2.png) [@rsx](https://community.icinga.com/u/rsx)\
**Post date:** [August 4, 2021, 1:55pm UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/7 "2021-08-04T13:55:47Z")

</div>

What is the result of this command?

> /usr/lib/nagios/plugins/check\_http --no-body -H www.mydomain.tld -I www.mydomain.tld -S -c 5 -f follow -w 2 --verbose

I’m not sure whether `-H` and `-I` works together.

---

<div class="post-metadata">

**Author:** ![gurubobnz](https://community.icinga.com/user_avatar/community.icinga.com/gurubobnz/32/7180_2.png) [@gurubobnz](https://community.icinga.com/u/gurubobnz)\
**Post date:** [September 23, 2023, 9:58am UTC](https://community.icinga.com/t/check-http-random-socket-timeout/7926/8 "2023-09-23T09:58:57Z")

</div>

I have a similar issue - we get random socket timeouts when using the http\_check tool. I have removed the http\_check tool completely from our Nagios installation and am running it in a bash loop, checking once every 15 seconds. It usually does a socket timeout once or twice a day. I cannot find a pattern to this yet.

I have noticed that this issue occurs both when I monitor our own infrastructure, and [google.com](http://google.com) which suggests it’s a networking issue. I have five checks running in rapid succession, like so: curl, http\_check, curl, http\_check, curl. When the socket timeout occurs the curl checks are all working fine, but the http\_check commands do not work.

This situation resolves itself pretty quickly. It doesn’t seem to coincide with any other events on the machine, and another machine in our office also exhibits the same issue, but not with the exact same regularity. We have recently changed out our gateway router to the internet, which I thought was the cause of this, but Nagios logs showed this has been happening for some time, just under the threshold for alerting so we didn’t notice it.

Running the exact same check at another site (from my home) works just fine.

I’m slowly getting to the point where I will reach out to our network provider, but at this time I am highly suspicious of the check\_http tool itself as being a contributor to this situation also, as ridiculous as that sounds.

Did you come to any conclusion with your investigation?
