LinuxCommandLibrary

httping

Ping HTTP/HTTPS servers to check availability

TLDR

Ping the specified URL

$ httping -g [url]
copy

Ping the web server on host and port
$ httping -h [host] -p [port]
copy

Ping the web server on host using a TLS connection
$ httping -l -g https://[host]
copy

Ping the web server on host using HTTP basic authentication
$ httping -g http://[host] -U [username] -P [password]
copy

SYNOPSIS

httping [OPTIONS] URL

Examples:
httping -g -c 10 https://www.google.com
httping -i 1 -s -l http://localhost:8080/health

PARAMETERS

URL
    The URL to send HTTP requests to (e.g., https://example.com/).

-i interval
    Set the interval in seconds between successive HTTP probes. Default is 1 second.

-c count
    Stop after sending count requests. If not specified, httping continues indefinitely.

-g
    Use HTTP GET requests instead of the default HEAD requests. Useful when HEAD is not supported or for full content retrieval time.

-l
    Follow HTTP redirects (3xx status codes) by following the Location header.

-s
    Enable SSL/TLS (HTTPS) support. This is implied if the URL starts with https://.

-t timeout
    Set a timeout in seconds for each individual request. Requests taking longer than this will be considered failed.

-x proxy_host:port
    Use an HTTP proxy for all requests.

-U user:password
    Provide HTTP Basic Authentication credentials for the target URL.

-h host
    Specify a custom Host header for the HTTP request, useful for virtual hosts.

-p port
    Specify the port number to connect to on the target server. Default is 80 for HTTP, 443 for HTTPS.

DESCRIPTION

httping is a command-line tool akin to ping(8), but specifically designed for HTTP and HTTPS requests. Instead of sending ICMP echo requests, it dispatches HTTP HEAD or GET requests to a specified URL and meticulously measures the round-trip time. It provides a continuous stream of valuable information including response times, HTTP status codes, and other crucial metrics, making it an indispensable utility for monitoring the availability and performance of web servers.

It serves as an excellent tool for diagnosing network issues affecting web services, validating SSL/TLS handshake times, or simply keeping a vigilant eye on a website's responsiveness. Unlike general-purpose tools such as curl or wget, httping excels in continuous monitoring and presenting concise summary statistics, mirroring the utility of ping for network connectivity. It is invaluable for system administrators and developers who require quick, insightful health checks into web application performance.

CAVEATS

httping primarily measures the time until the first byte of the response is received (or just headers for HEAD requests). This metric differs from a full page load time, which would encompass rendering and loading all associated assets like images and scripts. It does not execute JavaScript or render HTML.

While it can follow redirects with the -l option, complex redirect chains or client-side (JavaScript-based) redirects might not be fully handled. Proxy configurations can sometimes be intricate, requiring specific environment variables or explicit -x flags. As a client-side tool, httping provides insights from the perspective of the machine running it and may not reflect the full user experience from diverse geographical locations or varying network conditions.

OUTPUT INTERPRETATION

The standard output of httping typically displays the URL, the HTTP status code, and the response time for each request. For example, GET www.example.com:80 (HTTP/1.1 200) 1.23 ms. At the conclusion of the session, it presents a comprehensive summary including minimum, average, maximum, and standard deviation of response times, alongside the 'packet loss' percentage (indicating failed requests).

An HTTP 200 OK status signifies a successful request, while 4xx codes denote client-side errors (e.g., 404 Not Found) and 5xx codes indicate server-side errors (e.g., 500 Internal Server Error). The time measurements are critical for assessing web server performance and network latency.

COMMON USE CASES

Monitoring Web Server Availability: Continuously check if a website is up and responsive by running httping -i 5 example.com.

Performance Diagnosis: Utilize httping to compare response times from various network locations or under different network conditions to pinpoint performance bottlenecks.

Health Checks in Scripts: Integrate httping -c 1 -L https://your-service/health into automated scripts to perform silent health checks without verbose output.

SSL/TLS Handshake Verification: The -s option allows you to time and verify the SSL/TLS negotiation process, ensuring your HTTPS setup is functioning correctly.

HISTORY

httping was created by Michiel van der Vlist, with its initial release dating back to approximately 2002. Its development was spurred by the need for a straightforward, ping-like utility tailored specifically for HTTP and HTTPS services. It filled a crucial gap that traditional network diagnostics like ping (ICMP-based) and general-purpose downloaders such as curl and wget did not adequately address for continuous, web-centric monitoring. Over the years, httping has become a go-to tool for quick, at-a-glance health checks of web servers, establishing itself as a fundamental component in network troubleshooting and web server administration toolkits.

SEE ALSO

ping(8): Network troubleshooting utility using ICMP echo requests., curl(1): Command-line tool for transferring data with URL syntax, supporting various protocols including HTTP/HTTPS., wget(1): Non-interactive network downloader that retrieves files from web servers., ss(8): Utility to investigate sockets, providing more detailed information than netstat., traceroute(8): Network diagnostic tool for displaying the route and measuring transit delays of packets across an IP network.

Copied to clipboard