{"skill":{"slug":"model-usage-monitor","displayName":"Model Usage Monitor","summary":"监控并统计模型调用次数和成本，计算缓存命中率，支持实时监控与每小时自动告警。","description":"# model-usage-monitor Skill\n\nOpenClaw 模型使用监控与告警技能\n\n## ⚠️ Security & Permissions Declaration\n\n**This skill monitors log files and sends alerts. All operations are read-only except notifications:**\n\n| Operation | Purpose | Scope |\n|-----------|---------|-------|\n| Read semantic router log (`semantic_check.log`) | Parse model usage statistics | Read-only, local file |\n| Read OpenClaw logs | Detect usage anomalies | Read-only, local files |\n| Send alert notifications via OpenClaw messaging | Notify user of cost spikes | Local OpenClaw API only |\n\n**What this skill does NOT do:**\n- Does NOT modify any configuration or log files\n- Does NOT access external servers or APIs\n- Does NOT access model credentials directly\n- Does NOT require elevated privileges\n- **Read-only monitoring** — zero side effects on system state\n\n## 功能\n\n- 解析语义路由日志，统计模型使用分布\n- 估算各模型调用次数和成本\n- 计算缓存命中率\n- 每小时自动告警检查\n- 支持实时监控模式\n\n## 安装\n\n```bash\n# 技能已包含监控脚本和自动配置\n# 安装后自动创建每小时检查的 Cron Job\n```\n\n## 使用\n\n### 查看监控报告\n\n```bash\n# 完整报告\npython3 ~/.openclaw/workspace/.lib/model_usage_monitor_v2.py\n\n# JSON 格式\npython3 ~/.openclaw/workspace/.lib/model_usage_monitor_v2.py --format json\n\n# 仅检查告警\npython3 ~/.openclaw/workspace/.lib/model_usage_monitor_v2.py --alert-check\n```\n\n### 实时监控\n\n```bash\npython3 ~/.openclaw/workspace/.lib/model_usage_monitor_v2.py --live\n```\n\n## 告警阈值\n\n| 类型 | 阈值 | 说明 |\n|------|------|------|\n| Opus 调用频繁 | >5 次/小时 | 防止意外大量使用昂贵模型 |\n| Opus 成本过高 | >$0.50/小时 | 成本控制 |\n| 总成本过高 | >$2.00/小时 | 总体预算控制 |\n\n## 文件结构\n\n```\n.skills/model-usage-monitor/\n├── SKILL.md              # 本文件\n├── monitor.py            # 核心监控脚本\n├── setup.py              # 自动安装/配置\n└── config.json           # 默认配置\n```\n\n## 技术细节\n\n- 全部使用本地 Ollama 模型，零 API 调用\n- 只读日志文件，零侵入\n- 基于 semantic_check.log 和 gateway.log 分析\n","tags":{"latest":"1.0.1","analytics":"1.0.0","cost":"1.0.0","model":"1.0.0","monitor":"1.0.0","usage":"1.0.0"},"stats":{"comments":0,"downloads":691,"installsAllTime":2,"installsCurrent":2,"stars":1,"versions":2},"createdAt":1773108314277,"updatedAt":1778491796228},"latestVersion":{"version":"1.0.1","createdAt":1773290673290,"changelog":"Version 1.0.1 of model-usage-monitor\n\n- Added detailed security & permissions declaration to documentation, clarifying all operations are read-only except notifications.\n- Introduced new files, including setup and library modules, for improved installation and modular monitoring logic.\n- Updated documentation structure, including new README files in both English and Chinese.\n- Refined file organization with dedicated config and script directories.\n- No changes to monitoring logic or user-facing features.","license":"MIT-0"},"metadata":null,"owner":{"handle":"halfmoon82","userId":"s173a0sd7rjbb7s3bsayc8607s83n58t","displayName":"halfmoon82","image":"https://avatars.githubusercontent.com/u/261569221?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089846272}}