Files
telegram-customer-bot/view_stats.sh
2025-11-01 21:58:31 +08:00

31 lines
916 B
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 机器人统计查看脚本
echo "=========================================="
echo "📊 机器人使用统计"
echo "=========================================="
echo ""
echo "1⃣ 访问用户列表:"
grep -oE "用户 [0-9]+" logs/*.log 2>/dev/null | grep -oE "[0-9]+" | sort -u | nl
echo ""
echo "2⃣ 最近20条用户活动"
grep -E "用户 [0-9]+|新用户访问" logs/integrated_bot_detailed.log 2>/dev/null | tail -20
echo ""
echo "3⃣ 今日搜索统计:"
today=$(date +%Y-%m-%d)
grep "$today" logs/*.log 2>/dev/null | grep -c "镜像.*已转发" || echo "0"
echo ""
echo "4⃣ 缓存统计:"
sqlite3 cache.db "SELECT COUNT(*) FROM cache;" 2>/dev/null || echo "无缓存数据"
echo ""
echo "5⃣ 机器人运行时长:"
ps -p $(pgrep -f integrated_bot_ai.py) -o etime= 2>/dev/null || echo "未运行"
echo ""
echo "=========================================="