hy-app-monitor/AGENTS.md
2026-04-22 14:39:40 +08:00

43 lines
2.0 KiB
Markdown
Raw 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.

# hy-app-monitor Agent Guide
## 项目目标
- 这是部署在 `deploy` 机器上的轻量监控面板。
- 页面端口固定走 `2026`,不要再改回 `6666` 一类浏览器 unsafe port。
- 服务健康检查直接走各业务机器的 HTTP 接口。
- 主机 `CPU / 内存 / 磁盘 / 进程数` 统一走 `TAT` 远程采集,不额外安装 agent。
- `Nacos``MongoDB` 指标优先走 deploy 机直连,不需要额外 agent。
## 配置约定
- 项目根目录 `.env` 是运行时唯一配置源。
- `.env` 必须保留在本地和远端项目目录里,但不能提交到 Git。
- `.env.example` 只作为模板,不能写真实密钥。
- `TENCENT_SECRET_ID` / `TENCENT_SECRET_KEY` / `DEPLOY_REGION``.env` 读取。
- `NACOS_BASE_URL` / `NACOS_NAMESPACE_ID` / `MONGO_URI` 也从 `.env` 读取。
- `config/targets.json` 里的 `instanceId` 不能删,`TAT` 主机采集依赖它。
## 运行约定
- 正式运行优先使用 `systemd`
- `scripts/install_systemd.sh` 负责安装 unit 并启用开机自启。
- `scripts/start.sh` / `stop.sh` / `restart.sh` / `status.sh` 在检测到 unit 后应直接转调 `systemctl`
- `scripts/run_foreground.sh` 只给 `systemd` 用,不要把它改成后台模式。
## 部署约定
- 远端路径固定为 `/opt/hy-app-monitor`
- 部署入口是 `ops/deploy_via_tat.py`
- 该脚本需要把本地项目根目录 `.env` 同步到远端项目根目录 `.env`
- 远端 Python 运行时优先使用项目内 `.venv`
- `requirements-ops.txt` 里的依赖既服务于部署脚本,也服务于运行时 `TAT` 指标采集。
- Python 代码按模块维护,核心目录是 `monitor/``server.py` 只保留入口。
## 修改原则
- 不要把 `TAT` 采集替换成 agent 方案,除非用户明确要求。
- 不要把密钥写进版本库。
- 不要删除页面里的主机指标区块。
- Python 文件保持高注释密度,优先写清楚每个步骤在做什么。
- Python 文件顶部的 `import` 区域不写包用途注释。