#!/bin/bash # Verify Agents Script - checks that agents are responding # Usage: ./verify_agents.sh set -e echo "=== AGENT E2E VERIFICATION ===" echo "" # 1. Check prober metrics echo "1. Checking prober metrics..." PROBER_METRICS=$(curl -s http://localhost:9108/metrics 2>/dev/null || echo "FAIL") if echo "$PROBER_METRICS" | grep -q "agent_e2e_success"; then echo " ✅ Prober metrics available" echo "$PROBER_METRICS" | grep "agent_e2e_success" | head -3 else echo " ❌ Prober metrics NOT available (prober may not be running)" fi echo "" # 2. Check Prometheus targets echo "2. Checking Prometheus targets..." PROM_TARGETS=$(curl -s http://localhost:9090/api/v1/targets 2>/dev/null || echo "FAIL") if echo "$PROM_TARGETS" | grep -q "prober"; then echo " ✅ Prober found in Prometheus targets" else echo " ⚠️ Prober not in Prometheus targets yet" fi echo "" # 3. Direct agent ping test echo "3. Testing /debug/agent_ping..." PING_RESULT=$(curl -s -X POST http://localhost:9300/debug/agent_ping -H "Content-Type: application/json" -d '{}' 2>/dev/null || echo '{"error":"connection failed"}') echo " $PING_RESULT" echo "" # 4. Gateway health та список агентів echo "4. Gateway health та агенти..." HEALTH=$(curl -s http://localhost:9300/health 2>/dev/null || echo '{"status":"error"}') if echo "$HEALTH" | grep -q "healthy"; then echo " ✅ Gateway healthy" AGENTS_COUNT=$(echo "$HEALTH" | grep -o '"agents_count":[0-9]*' | cut -d: -f2) echo " Агентів у реєстрі: ${AGENTS_COUNT:-?}" if command -v jq >/dev/null 2>&1; then echo " Агенти (prompt | telegram token):" echo "$HEALTH" | jq -r '.agents | to_entries[] | " - \(.key): prompt=\(.value.prompt_loaded) token=\(.value.telegram_token_configured)"' 2>/dev/null || echo "$HEALTH" | head -c 400 else echo " (встановіть jq для детального виводу: .agents)" echo "$HEALTH" | head -c 400 fi else echo " ❌ Gateway unhealthy: $HEALTH" fi echo "" echo "" # 5. Webhook test echo "5. Testing webhook (Helion)..." WEBHOOK=$(curl -s -X POST http://localhost:9300/helion/telegram/webhook \ -H "Content-Type: application/json" \ -d '{"update_id":1}' 2>/dev/null || echo '{"error":"failed"}') echo " $WEBHOOK" echo "" echo "=== VERIFICATION COMPLETE ==="