Web服务监控系统

自动监控所有Web服务状态每20分钟检查一次如有服务停止则发送邮件通知。

功能特点

  • 定时检查多个Web服务端口
  • 自动检测服务是否存活
  • 发现停止服务时发送HTML格式邮件通知
  • 邮件包含启动命令,方便快速恢复

监控的服务

服务名称 端口 健康检查路径
PDF翻译助手 V2 19000 /api/health
LLM Index RAG 19001 /api/stats
碎片信息记录 19009 /api/notes
ParamHub Python 19010 /api/stats
产品参数爬取 API 19011 /api/products
产品参数爬取 后台 19012 /
LLM Proxy API 19007 /health
LLM Proxy 后台 19008 /api/stats

使用方法

手动检查

python3 monitor.py

配置定时任务

# 添加到crontab
crontab -e

# 每20分钟检查一次
*/20 * * * * /usr/bin/python3 /home/xian/.openclaw/workspace-coder/works/service-monitor/monitor.py >> /home/xian/.openclaw/workspace-coder/works/service-monitor/monitor.log 2>&1

配置说明

修改 monitor.py 中的配置:

# 通知邮箱
NOTIFY_EMAIL = "your-email@example.com"

# 服务列表
SERVICES = [
    {"name": "服务名称", "port": 端口号, "path": "/health", "start_cmd": "启动命令"},
    # ...
]

依赖

  • Python 3
  • urllib (内置)
  • email-sender 技能 (邮件发送)

文件说明

文件 说明
monitor.py 主监控脚本
status.json 上次检查状态
monitor.log 运行日志

版本历史

  • v1.0.0 (2026-04-10) - 初始版本支持8个服务监控
Description
Web服务监控系统 - 定时检查服务状态,停止时发送邮件通知
Readme 31 KiB
Languages
Python 100%