check_http

Runs check_http to check HTTP(s) connections. It wraps the plugin from https://github.com/sni/check_http_go

Implementation

WindowsLinuxFreeBSDmacOS
✅✅✅✅

Usage

  check_http [OPTIONS]

Application Options:
  -H, --hostname=                                   Host name using Host headers
  -I, --IP-address=                                 IP address or host name
  -j, --method=                                     Set HTTP method (default: GET)
  -P, --post=                                       Data to send in the request body. Uses POST unless --method is set.
                                                    Set Content-Type with --header (for example --header 'Content-Type:
                                                    application/json')
  -u, --uri=                                        URI to request (default: /)
  -e, --expect=                                     Comma-separated list of expected HTTP response statuses. Defaults:
                                                    1XX and 2XX are OK. 3XX depends on --onredirect. 4XX is WARNING.
                                                    5XX is CRITICAL
  -s, --string=                                     String to expect in the content
      --base64-string=                              Base64-encoded string to expect in the content
  -A, --useragent=                                  UserAgent to send (default: check_http)
  -a, --authorization=                              Basic authorization header in the format '[username]:[password]'
  -k, --header=                                     Additional HTTP header. Repeat this option to add more headers
  -C, --certificate=                                Check certificates instead of content. Give the warning threshold
                                                    in days remaining and an optional critical threshold:
                                                    warn_days[,<crit_days>]
      --tls-min=[1.0|1.0+|1.1|1.1+|1.2|1.2+|1.3]    Minimum supported TLS version. A plus suffix also sets the maximum
                                                    to the latest version: 1.3
      --tls-max=[1.0|1.1|1.2|1.3]                   Maximum supported TLS version
      --proxy=                                      Proxy to use
  -r, --regex=                                      Search page for case-sensitive regex string
  -R, --regexi=                                     Search page for case-insensitive regex string
  -f, --onredirect=<options>                        Redirect strategy: ok, warning, critical, follow, sticky,
                                                    stickyport. The ok/warning/critical options return immediately. The
                                                    follow option uses the new URL from Go's HTTP client. The sticky
                                                    option keeps the hostname after a redirect. The stickyport option
                                                    also keeps the port.
      --max-buffer-size=                            Max buffer size to read response body (max.: 100MB) (default: 1MB)
  -t, --timeout=                                    Connection timeout. Without a time unit suffix, the value is in
                                                    seconds (default: 10)
  -w, --warning=                                    If the request and response take longer than this threshold, return
                                                    a warning. Without a time unit suffix, use seconds. The check
                                                    truncates the value to milliseconds. (default: 30)
  -c, --critical=                                   If the request and response take longer than this threshold, return
                                                    critical. Without a time unit suffix, use seconds. The check
                                                    truncates the value to milliseconds. (default: 60)
      --wait-for-interval=                          Retry interval (default: 2s)
      --wait-for-max=                               Time to wait for success (max.: 180s)
      --interim=                                    Interval time after successful request for consecutive mode
                                                    (default: 1s)
      --consecutive=                                Number of consecutive successful requests required (max.: 5)
                                                    (default: 1)
  -p, --port=                                       Port number
      --max-redirs=                                 Maximum number of redirects to follow
      --no-discard                                  Raise error when the response body is larger than max-buffer-size
      --wait-for                                    Retry until successful when enabled
  -S, --ssl                                         Use HTTPS
      --sni                                         Enable SNI
  -4                                                Use tcp4 only
  -6                                                Use tcp6 only
  -v, --verbose                                     Show verbose output
      --show-body                                   Print body content below status line
      --ignore-certificate-chain                    By default, certificate checks examine all certificates. Use this
                                                    option to check only the leaf (final) certificate.
      --check-cn                                    Check that the leaf certificate's Subject Common Name matches the
                                                    hostname exactly. Modern websites rarely use Common Name. Subject
                                                    Alternative Name fields are more common and take priority when
                                                    present. Disabled by default.
      --check-san                                   Check Subject Alternative Names against the hostname. SANs list the
                                                    hostnames and IP addresses valid for the certificate. Ignore SANs
                                                    on Certificate Authority certificates, which sign other
                                                    certificates instead of verifying hostnames. Disabled by default.
      --ignore-not-after                            Ignore NotAfter. Certificates are invalid after this timestamp.
      --ignore-not-before                           Ignore NotBefore. Certificates are invalid before this timestamp.
      --ignore-signature-algorithm                  Ignore the signature algorithm. Some algorithms are deprecated
                                                    because they are insecure.

Help Options:
  -h, --help                                        Show this help message

Examples

Default Check

Alert if the HTTP server does not respond:

check_http -H omd.consol.de
HTTP OK - HTTP/1.1 200 OK - 573 bytes in 0.001 second response time | ...

Check for a specific string and response code:

check_http -H omd.consol.de -S -u "/docs/snclient/" -e 200,304 -s "consol" -vvv
HTTP OK - Status line output "HTTP/2.0 200 OK" matched "200,304", Response body matched "consol"...

Example using check_snclient and Naemon

Naemon Config

define command{
    command_name         check_snclient
    command_line         $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$
}

define service {
    host_name            testhost
    service_description  check_http
    use                  generic-service
    check_command        check_snclient!check_http!'-H' 'omd.consol.de' '--uri=/docs' '-S'
}