| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import argparse | |
| import sys | |
| import requests | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Check VLAC service /healthcheck endpoints.") | |
| parser.add_argument( | |
| "--urls", | |
| required=True, | |
| help="Comma-separated base URLs, e.g. http://localhost:8111,http://localhost:8112", | |
| ) | |
| parser.add_argument("--timeout", type=float, default=10.0, help="Request timeout in seconds") | |
| args = parser.parse_args() | |
| urls = [u.strip().rstrip("/") for u in args.urls.split(",") if u.strip()] | |
| if not urls: | |
| print("No URLs provided.", file=sys.stderr) | |
| sys.exit(2) | |
| ok_any = False | |
| for base in urls: | |
| try: | |
| resp = requests.post(f"{base}/healthcheck", timeout=args.timeout) | |
| if resp.ok: | |
| print(f"OK {base}") | |
| ok_any = True | |
| else: | |
| print(f"BAD {base} status={resp.status_code}", file=sys.stderr) | |
| except Exception as exc: | |
| print(f"ERR {base} {exc}", file=sys.stderr) | |
| sys.exit(0 if ok_any else 1) | |
| if __name__ == "__main__": | |
| main() | |