Python
public
HTTP Endpoint Health
Share this script safely, inspect its metadata, and copy the exact command you need.
Ready to run
One-liner
curl -fsSL https://runny.sh/r/S9Z3JY6HK2ZP | python3
Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.625
At a glance
Script metadata
Readable before runnable
Preview
#!/usr/bin/env python3
# HTTP endpoint health
# Read-only GET of URLs from argv (default https://example.com). Prints status and time.
# Exit 0 if healthy, 1 if 4xx or slow, 2 if 5xx or the request fails.
# Hosted on Runny.sh. Review the script page before you run it.
from __future__ import annotations
import sys
import time
import urllib.error
import urllib.request
def probe(url: str) -> int:
req = urllib.request.Request(
url,
method="GET",
headers={"User-Agent": "Runny.sh-http-endpoint-health"},
)
started = time.monotonic()
try:
with urllib.request.urlopen(req, timeout=15) as resp:
code = int(resp.getcode() or 0)
elapsed = time.monotonic() - started
print(f"{url} {code} {elapsed:.3f}s")
if elapsed >= 5:
print(" WARNING: slower than 5s")
return 1
print(" OK")
return 0
except urllib.error.HTTPError as exc:
elapsed = time.monotonic() - started
print(f"{url} {exc.code} {elapsed:.3f}s")
if exc.code >= 500:
print(" CRITICAL: server error")
return 2
print(" WARNING: HTTP error")
return 1
except Exception as exc:
print(f"{url} ERROR {exc}")
print(" CRITICAL: request failed")
return 2
def main() -> int:
urls = sys.argv[1:] or ["https://example.com"]
print("=== HTTP endpoint health ===")
print(f"Targets: {len(urls)}")
print()
worst = 0
for url in urls:
rc = probe(url)
if rc > worst:
worst = rc
print()
if worst == 0:
print("Result: HEALTHY")
elif worst == 1:
print("Result: WARNING")
else:
print("Result: CRITICAL")
return worst
if __name__ == "__main__":
sys.exit(main())
Raw endpointhttps://runny.sh/r/S9Z3JY6HK2ZP
See something unsafe?
Report this script
Tell us why it should come down. Anyone can also report a URL at /abuse.