#!/bin/bash

# Verify Key Services Status

set -euo pipefail

echo "=== Verifying Key Services ==="
echo ""

# NPMplus
echo "=== NPMplus (VMID 10233) ==="
ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 root@192.168.11.10 \
  "ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 root@r630-01 'pct exec 10233 -- docker ps --format \"table {{.Names}}\t{{.Status}}\t{{.Ports}}\" 2>&1 | head -5'"

echo ""
echo "=== NPMplus HTTP Test ==="
curl -s -o /dev/null -w "HTTP Status: %{http_code}\n" --connect-timeout 2 http://192.168.11.167:80 2>&1 || echo "NPMplus unreachable"

echo ""
echo "=== Explorer (VMID 5000) ==="
ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 root@192.168.11.10 \
  "ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 root@r630-02 'pct status 5000 2>&1'"

echo ""
echo "=== Explorer Network Config ==="
ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 root@192.168.11.10 \
  "ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 root@r630-02 'pct config 5000 | grep -E \"net|ip\" | head -5'"

echo ""
echo "=== Explorer HTTP Test ==="
curl -s -o /dev/null -w "HTTP Status: %{http_code}\n" --connect-timeout 2 http://192.168.11.140:80 2>&1 || echo "Explorer unreachable"
