Repository: DataDog/dd-agent

Issue:
[http] HTTP Check logs error 
*_Output of the [info page](https://help.datadoghq.com/hc/en-us/articles/203764635-Agent-Status-and-Information) *_

<details>

```
===================
Collector (v 5.9.1)
===================

  Status date: 2016-10-09 11:44:45 (13s ago)
  Pid: 15254
  Platform: Linux-3.13.0-96-generic-x86_64-with-Ubuntu-14.04-trusty
  Python Version: 2.7.12, 64bit
  Logs: <stderr>, /var/log/datadog/collector.log

  Clocks
  ======

    NTP offset: -0.0007 s
    System UTC time: 2016-10-09 11:44:59.442160

  Paths
  =====

    conf.d: /etc/dd-agent/conf.d
    checks.d: /opt/datadog-agent/agent/checks.d

  Hostnames
  =========

    ec2-hostname: <REDACTED>
    local-ipv4: <REDACTED>
    local-hostname: <REDACTED>
    public-hostname: <REDACTED>
    hostname: <REDACTED>
    instance-id: <REDACTED>
    public-ipv4: <REDACTED>
    agent-hostname: <REDACTED>
    socket-fqdn: <REDACTED>

  Checks
  ======

    nginx
    -----
      - instance #0 [OK]
      - Collected 7 metrics, 0 events & 2 service checks

    network
    -------
      - instance #0 [OK]
      - Collected 15 metrics, 0 events & 1 service check

    ntp
    ---
      - Collected 0 metrics, 0 events & 1 service check

    disk
    ----
      - instance #0 [OK]
      - Collected 24 metrics, 0 events & 1 service check

    http_check
    ----------
      - instance #0 [WARNING]
          Warning: Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
          Warning: Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
          Warning: Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
          Warning: Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
          Warning: Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
          Warning: Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
      - instance #1 [OK]
      - instance #2 [OK]
      - Collected 3 metrics, 0 events & 7 service checks


  Emitters
  ========

    - http_emitter [OK]

===================
Dogstatsd (v 5.9.1)
===================

  Status date: 2016-10-09 11:44:57 (2s ago)
  Pid: 15251
  Platform: Linux-3.13.0-96-generic-x86_64-with-Ubuntu-14.04-trusty
  Python Version: 2.7.12, 64bit
  Logs: <stderr>, /var/log/datadog/dogstatsd.log

  Flush count: 34
  Packet Count: 0
  Packets per second: 0.0
  Metric count: 1
  Event count: 0
  Service check count: 0

===================
Forwarder (v 5.9.1)
===================

  Status date: 2016-10-09 11:44:57 (3s ago)
  Pid: 15253
  Platform: Linux-3.13.0-96-generic-x86_64-with-Ubuntu-14.04-trusty
  Python Version: 2.7.12, 64bit
  Logs: <stderr>, /var/log/datadog/forwarder.log

  Queue Size: 447 bytes
  Queue Length: 1
  Flush Count: 116
  Transactions received: 51
  Transactions flushed: 50
  Transactions rejected: 0
```

</details>

**Additional environment details (Operating System, Cloud provider, etc):**
- Ubuntu 14.04.5 LTS
- AWS

**Steps to reproduce the issue:**
1. Create `http_check.yaml` against 1+ https:// enabled sites, and disable `disable_ssl_validation` (note: the double-negative use of this variable is confusing.)
2. Restart Agent

**Describe the results you received:**

from `/var/log/datadog/collector.log`:

```
2016-10-09 11:39:21 UTC | INFO | dd.collector | checks.http_check(network_checks.py:94) | Starting Thread Pool
2016-10-09 11:39:21 UTC | ERROR | dd.collector | checks.http_check(network_checks.py:152) | Failed to process instance ''.
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/checks/network_checks.py", line 138, in _process
    statuses = self._check(instance)
  File "/opt/datadog-agent/agent/checks.d/http_check.py", line 319, in _check
    status, msg = self.check_cert_expiration(instance, timeout, instance_ca_certs)
  File "/opt/datadog-agent/agent/checks.d/http_check.py", line 449, in check_cert_expiration
    exp_date = datetime.strptime(cert['notAfter'], "%b %d %H:%M:%S %Y %Z")
AttributeError: 'module' object has no attribute '_strptime'
2016-10-09 11:39:21 UTC | INFO | dd.collector | checks.collector(collector.py:514) | Finished run #1. Collection time: 4.35s. Emit time: 0.02s
2016-10-09 11:39:40 UTC | WARNING | dd.collector | checks.http_check(__init__.py:679) | Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
2016-10-09 11:39:40 UTC | WARNING | dd.collector | checks.http_check(__init__.py:679) | Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
2016-10-09 11:39:40 UTC | WARNING | dd.collector | checks.http_check(__init__.py:679) | Using events for service checks is deprecated in favor of monitors and will be removed in future versions of the Datadog Agent.
...
(repeat infinitely)
```

**Describe the results you expected:**
No log errors.

**Additional information you deem important (e.g. issue happens only occasionally):**

The WARNINGs that appear both in the `info` and the collector logs have previously been reported in #1999 last year, and persist. I think this is not related to this issue. I might be wrong.



Discussion:
I'm experiencing the same issue. Also using an https URL and getting issues referencing _strptime from the datetime object.


Resolving patch:
diff --git a/checks.d/http_check.py b/checks.d/http_check.py
--- a/checks.d/http_check.py
+++ b/checks.d/http_check.py
@@ -4,6 +4,7 @@
 
 # stdlib
 from datetime import datetime
+import _strptime # noqa
 import os.path
 from os import environ
 import re


Test patch: