#!/bin/bash
# Host-side healthcheck for fleet-prometheus.
# Mirrors the vikunja pattern: confirm the container runs, then probe the API
# from the host.

# Container must be running
if ! docker ps --filter "name=fleet-prometheus" --filter "status=running" | grep -qw "fleet-prometheus"; then
    echo "[FAIL] fleet-prometheus container is not running"
    exit 1
fi

# Prometheus must report itself healthy
if ! curl -sf http://localhost:9090/-/healthy > /dev/null; then
    echo "[FAIL] Prometheus is not healthy on :9090"
    exit 1
fi

echo "[OK] fleet-prometheus is healthy"
exit 0
