#!/bin/bash
# Sanguo Quant 查看所有Agent监控状态
# 文件位置：项目根目录/status_all_agents.sh

# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

echo "========================================="
echo "📊 Sanguo Quant 所有Agent监控状态"
echo "时间: $(date)"
echo "========================================="
echo ""

# 项目根目录
PROJECT_DIR="/Users/chufeng/.openclaw/agents/main/workspace/projects/sanguo_quant_live"
cd "$PROJECT_DIR" || {
    echo -e "${RED}❌ 项目目录不存在: $PROJECT_DIR${NC}"
    exit 1
}

# 所有Agent列表
AGENTS="pangtong zhangfei guanyu zhaoyun simayi jiangwei"

echo "📋 Agent列表: $AGENTS"
echo ""

for agent in $AGENTS; do
    echo -n "$agent: "
    
    # 检查进程
    if ps aux | grep -q "agent_monitor_fixed.sh $agent" | grep -v grep; then
        PIDs=$(ps aux | grep "agent_monitor_fixed.sh $agent" | grep -v grep | awk '{print $2}')
        COUNT=$(echo "$PIDs" | wc -l)
        echo -e "${GREEN}✅ 运行中 ($COUNT 个进程)${NC}"
        echo "    PID: $PIDs"
    else
        echo -e "${RED}❌ 未运行${NC}"
    fi
    echo ""
done

echo "========================================="
echo "📝 日志文件位置:"
for agent in $AGENTS; do
    echo "  $agent: ${agent}_monitor.log"
done
echo "========================================="
echo "🔍 查看日志: tail -f <agent>_monitor.log"
echo "========================================="
