Add the locked pricing service, trusted-agent pipeline, Ansible deployments, security gates, recovery runbooks, prerequisite evidence, and preparation manual. Prepared with Codex assistance. Vincent explicitly authorized this local commit and will handle the push. Assessed releases and recovery exercises remain pending.
49 lines
2.1 KiB
Python
49 lines
2.1 KiB
Python
"""Sample public HTTPS health during release/recovery; failures are evidence."""
|
|
|
|
import argparse
|
|
import csv
|
|
from datetime import datetime, timezone
|
|
import json
|
|
from pathlib import Path
|
|
import time
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--url', choices=['https://app.yebilly.me', 'https://staging.yebilly.me'], required=True)
|
|
parser.add_argument('--seconds', type=int, default=600)
|
|
parser.add_argument('--interval', type=float, default=1)
|
|
parser.add_argument('--output', required=True)
|
|
args = parser.parse_args()
|
|
if not 1 <= args.seconds <= 1800 or args.interval < 0.5:
|
|
parser.error('Use 1-1800 seconds and at least 0.5 seconds between samples')
|
|
output = Path(args.output)
|
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
deadline = time.monotonic() + args.seconds
|
|
with output.open('w', newline='') as stream:
|
|
writer = csv.writer(stream)
|
|
writer.writerow(['started_utc', 'elapsed_seconds', 'http_status', 'status', 'version', 'error'])
|
|
while time.monotonic() < deadline:
|
|
started = datetime.now(timezone.utc).isoformat()
|
|
clock = time.monotonic()
|
|
code, status, version, error = '', '', '', ''
|
|
try:
|
|
with urllib.request.urlopen(args.url + '/health', timeout=2) as response:
|
|
code = response.status
|
|
body = json.load(response)
|
|
status, version = body.get('status', ''), body.get('version', '')
|
|
except urllib.error.HTTPError as failure:
|
|
code, error = failure.code, type(failure).__name__
|
|
except (OSError, ValueError, urllib.error.URLError) as failure:
|
|
error = type(failure).__name__
|
|
writer.writerow([started, round(time.monotonic() - clock, 3), code, status, version, error])
|
|
stream.flush()
|
|
time.sleep(max(0, args.interval - (time.monotonic() - clock)))
|
|
print(f'Saved samples to {output}; inspect failed samples and gaps, not just the exit status')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|