joy-cli/domains/weixiaoduo.sh
feibisi 3874b562c3 feat: joy CLI Python 2.0 — 50 命令全量重写 + pip 全集群部署
- 50 命令:patrol/health/board/recall/poke/who/inbox/mind/message/team 等
- 异步并行 SSH (asyncio subprocess)
- 命令注册表 + @command decorator + 插件扩展架构
- 环境检测 (Mac/VM/agent 身份)
- JSON 输出契约 (stdout=成功, stderr=错误 code)
- 权限模型 (agent 身份检测 + 环境限制)
- pytest 23/23 通过
- deploy-joy.sh 全集群 16 VM 部署脚本 (含 PEP 668 兼容)
- 旧 bash 版归档到 archive/commands.bash/

Closes: joy CLI 2.0 迁移
2026-07-07 11:38:03 +08:00

69 lines
2.1 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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.

# weixiaoduo 领域检查 — 电商网站 + 在线率(高价值业务)
domain_check() {
local result="{"
local issues=()
local journal=~/office/weixiaoduo/journal.jsonl
[[ ! -f "$journal" ]] && { echo '{"status":"no_data","domain":"weixiaoduo"}'; return; }
# 1. 网站告警摘要(最近 2h
local alerts
alerts=$(tail -30 "$journal" 2>/dev/null | python3 -c "
import json, sys, time
now = time.time()
alert_count = 0
sites = set()
for line in sys.stdin:
line = line.strip()
if not line: continue
try:
d = json.loads(line)
ts_str = d.get('ts','')
if ts_str:
t = time.mktime(time.strptime(ts_str[:19], '%Y-%m-%dT%H:%M:%S'))
if now - t > 7200: continue
se = d.get('self_eval','')
if '告警' in se:
alert_count += 1
# Extract site URL
import re
urls = re.findall(r'https?://[^\s]+', se)
for u in urls:
sites.add(u[:50])
except: pass
print(f'{alert_count} alerts on {len(sites)} sites')
for s in list(sites)[:3]:
print(f' - {s}')
" 2>/dev/null)
if [[ -n "$alerts" ]]; then
result+="\"alerts\":\"$(echo "$alerts" | head -1)\""
local alert_count
alert_count=$(echo "$alerts" | head -1 | grep -o '[0-9]\+' | head -1)
(( alert_count > 0 )) && issues+=("网站告警: $alerts")
else
result+="\"alerts\":\"0\""
fi
# 2. 在线率
local uptime_info
uptime_info=$(tail -10 "$journal" 2>/dev/null | python3 -c "
import json, sys
for line in sys.stdin:
line = line.strip()
if not line: continue
try:
d = json.loads(line)
se = d.get('self_eval','')
if '在线' in se or 'online' in se.lower() or 'offline' in se.lower():
print(se[:120])
except: pass
" 2>/dev/null | tail -2)
[[ -n "$uptime_info" ]] && result+=",\"uptime_check\":\"active\""
result+=",\"issues\":$(jq -nc '$ARGS.positional' --args ${issues[@]+"${issues[@]}"})}"
echo "$result" | jq .
}
domain_summary() {
echo "电商网站监控"
}