{"id":50706647,"url":"https://github.com/qzhqzh/eyes","last_synced_at":"2026-06-09T12:31:50.392Z","repository":{"id":362530351,"uuid":"1259387332","full_name":"qzhqzh/eyes","owner":"qzhqzh","description":"👁 服务健康检查工具 — 从 nginx 自动发现子域名服务，支持 Docker/Systemd/HTTP/Port/Command 检查，邮件告警","archived":false,"fork":false,"pushed_at":"2026-06-04T15:23:41.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T17:13:35.995Z","etag":null,"topics":["docker","healthcheck","monitoring","nginx","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qzhqzh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-04T13:06:48.000Z","updated_at":"2026-06-04T15:24:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/qzhqzh/eyes","commit_stats":null,"previous_names":["qzhqzh/eyes"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/qzhqzh/eyes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qzhqzh%2Feyes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qzhqzh%2Feyes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qzhqzh%2Feyes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qzhqzh%2Feyes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qzhqzh","download_url":"https://codeload.github.com/qzhqzh/eyes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qzhqzh%2Feyes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34107865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","healthcheck","monitoring","nginx","python"],"created_at":"2026-06-09T12:31:49.434Z","updated_at":"2026-06-09T12:31:50.381Z","avatar_url":"https://github.com/qzhqzh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eyes — 服务健康检查工具\n\n一行命令检查本机所有服务是否正常运行。支持邮件告警和每日报告。\n\n**特性：**\n- 支持 Docker 容器、Systemd 服务、HTTP 端点、端口监听、自定义命令\n- **Nginx 自动发现**：从 nginx 配置自动识别子域名服务，无需手动维护\n- 邮件告警（SMTP）和每日报告\n- 终端彩色输出、JSON 输出、实时刷新\n\n## 快速开始\n\n```bash\n# 1. 安装依赖\npip install pyyaml\n\n# 2. 复制配置文件\ncp config.example.yaml config.yaml\n\n# 3. 编辑配置，填入你的邮箱和 SMTP 信息\nvim config.yaml\n\n# 4. 运行检查\npython3 check.py\n```\n\n## 目录结构\n\n```\neyes/\n├── check.py                主脚本\n├── config.example.yaml     配置模板（可提交到公开仓库）\n├── config.yaml             实际配置（含密码，已 gitignore）\n├── .gitignore              Git 忽略规则\n└── conf.d/                 服务列表（按分类存放）\n    ├── docker.yaml         Docker 容器（手动管理）\n    ├── http.yaml           HTTP 端点（手动管理）\n    ├── systemd.yaml        Systemd 服务\n    ├── port.yaml           端口监听\n    ├── command.yaml        自定义命令\n    ├── _nginx_docker.yaml  Nginx 自动发现（由 --sync 生成）\n    └── _nginx_http.yaml    Nginx 自动发现（由 --sync 生成）\n```\n\n## 用法\n\n```bash\npython3 check.py              # 终端检查\npython3 check.py --json       # JSON 输出\npython3 check.py --watch 10   # 每 10 秒刷新\npython3 check.py --quiet      # 只显示失败项\npython3 check.py --alert      # 有失败才发邮件\npython3 check.py --report     # 始终发邮件报告\n\n# Nginx 自动发现（推荐）\npython3 check.py --sync             # 同步 nginx 路由 + 终端检查\npython3 check.py --sync --alert     # 同步 + 异常发邮件\npython3 check.py --sync --report    # 同步 + 每日报告\n```\n\n## Nginx 自动发现\n\n如果你使用 nginx 反向代理，`--sync` 会自动：\n\n1. 扫描 `nginx/conf.d/*.conf` 文件\n2. 解析 `server_name` → `proxy_pass` 端口映射\n3. 找到每个端口对应的 Docker 容器\n4. 自动生成 `_nginx_docker.yaml` 和 `_nginx_http.yaml`\n5. 移除已下线服务的监控条目\n\n**使用方式：**\n\n```bash\n# 设置 nginx 配置目录（默认 /etc/nginx/conf.d）\npython3 check.py --sync --nginx-conf-dir /path/to/nginx/conf.d\n```\n\n**工作流：**\n- 新增服务：添加 nginx conf → 下次 `--sync` 自动发现\n- 移除服务：删除 nginx conf → 下次 `--sync` 自动排除\n- 手动服务：在 `docker.yaml` / `http.yaml` 中维护\n\n## 增删服务\n\n### 手动添加\n\n直接编辑 `conf.d/` 下对应文件：\n\n```bash\n# 加一个 Docker 容器\necho '- { name: \"新服务\", target: my-container-1 }' \u003e\u003e conf.d/docker.yaml\n\n# 删一个：注释掉或删掉那一行\n# - { name: \"旧服务\", target: old-container }\n\n# 加一个新分类：新建 conf.d/xxx.yaml\n```\n\n### 自动发现（推荐）\n\n使用 nginx 反向代理的服务无需手动添加：\n\n```bash\n# 1. 添加 nginx 配置\ncat \u003e /etc/nginx/conf.d/my-service.conf \u003c\u003c 'EOF'\nserver {\n    listen 80;\n    server_name my-service.example.com;\n    location / {\n        proxy_pass http://127.0.0.1:8080;\n    }\n}\nEOF\n\n# 2. 重新加载 nginx\nnginx -s reload\n\n# 3. 运行同步（自动发现新服务）\npython3 check.py --sync\n```\n\n## 定时任务\n\n```bash\n# 每小时整点检查（自动同步 nginx + 异常发邮件）\n0 * * * * cd /path/to/eyes \u0026\u0026 python3 check.py --sync --alert \u003e\u003e /var/log/eyes.log 2\u003e\u00261\n\n# 每天 9:00 发完整报告\n0 9 * * * cd /path/to/eyes \u0026\u0026 python3 check.py --sync --report \u003e\u003e /var/log/eyes.log 2\u003e\u00261\n```\n\n## 退出码\n\n- `0` — 全部通过\n- `1` — 有失败项\n\n## 环境变量（可选）\n\n可以通过环境变量覆盖配置：\n\n```bash\nexport EYES_EMAIL_FROM=\"alert@example.com\"\nexport EYES_EMAIL_TO=\"admin@example.com\"\nexport EYES_SMTP_HOST=\"smtp.example.com\"\nexport EYES_SMTP_PASSWORD=\"your_password\"\n\npython3 check.py\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqzhqzh%2Feyes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqzhqzh%2Feyes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqzhqzh%2Feyes/lists"}