- 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 迁移
69 lines
2.1 KiB
Bash
69 lines
2.1 KiB
Bash
# 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 "电商网站监控"
|
||
}
|