简介
纯Python零依赖的网站监控工具,支持可用性检测、响应时间测量和内容变更追踪,适合DevOps自动化和定时巡检场景。
原始描述
Lightweight website uptime monitor. Check if URLs are up, measure response times, detect content changes via hashing, and verify expected content. Zero depen...
通过你的 Agent 添加
安装目录:website-monitor/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Website Monitor 是一款基于 Python 标准库开发的轻量级网站监控工具,无需安装任何外部依赖即可运行。用户通过命令行输入一个或多个 URL,工具会自动执行 HTTP GET 请求,返回详细的状态信息。
基础使用极其简单:
python main.py https://example.com
该命令会输出网站的 HTTP 状态码、响应时间、页面大小和内容哈希值。工具支持多 URL 批量检查、自定义超时设置、预期状态码验证、页面内容文本匹配以及基于 SHA-256 哈希的内容变化检测。
进阶功能包括:
--hash-check比对历史哈希值检测页面内容变更--contains验证页面是否包含特定文本(适合监控状态页)--expect验证非 200 状态码(如 301 重定向)--json输出机器可读格式,便于集成到监控系统
工具设计考虑到了自动化场景,返回标准退出码(0 表示全部正常,1 表示有异常),完美适配 shell 脚本和 cron 定时任务。
显著优点
1. 零依赖安全架构 完全基于 Python 3 标准库(urllib、hashlib、time、json、sys、argparse),消除了第三方依赖带来的供应链攻击风险。无需 pip install,开箱即用。
2. 极简部署 单文件 123 行代码,体积小巧,可在任何安装 Python 3 的环境中直接运行,包括资源受限的边缘设备和容器环境。
3. 功能完整 涵盖网站监控的核心需求:可用性检测、性能测量(毫秒级)、内容完整性校验、变更追踪,输出格式兼顾人类可读和机器解析。
4. 行为透明可控 仅向用户明确指定的 URL 发起请求,有 10 秒超时保护,清晰的 User-Agent 标识,无隐藏网络行为或数据收集。
潜在缺点与局限性
1. 功能相对基础 不支持高级监控功能如:SSL 证书过期检测、HTTP/2 或 HTTP/3 协议、自定义请求头、Cookie 会话保持、POST/PUT 等请求方法、分布式探测节点。
2. 同步阻塞模型 使用 urllib 的同步请求,多 URL 检查时为串行执行,大规模监控场景下效率低于异步方案(如基于 aiohttp 的实现)。
3. 无持久化存储 不内置数据库或日志文件管理,历史数据、趋势分析需用户自行对接外部系统。
4. 告警机制缺失 无内置邮件、短信、Webhook 等告警通知功能,需配合 cron + 邮件工具或外部监控平台实现。
5. 认证支持有限 不支持需要登录、Token 认证或复杂鉴权的站点监控。
适合的目标群体
- 个人开发者/小型团队:需要快速搭建简单监控,不愿维护复杂基础设施
- DevOps 运维人员:作为现有监控体系的轻量补充,或用于脚本自动化
- 安全研究员:审计网站可用性变化,检测内容篡改
- CI/CD 流水线:在部署后验证服务是否正常启动
- 边缘设备/IoT 场景:资源受限环境下运行监控探针
使用风险
常规技术风险:
- 被监控站点可能因频繁请求而封禁 IP,建议合理设置检查间隔
- 网络不稳定或 DNS 解析失败会导致误报,建议结合重试策略
- 大规模 URL 列表检查性能受限,建议分批执行或改用专业监控平台
合规风险:
- 仅对您拥有权限的目标发起监控,避免扫描他人内部网络或触发安全警报
- 部分网站服务条款可能禁止自动化访问,使用前请确认合规性
技能正文
name: website-monitor description: Lightweight website uptime monitor. Check if URLs are up, measure response times, detect content changes via hashing, and verify expected content. Zero dependencies. triggers:
- check website
- is site up
- monitor url
- website status
- uptime check
- ping website
Website Monitor
A zero-dependency Python tool for checking website availability, measuring response times, and detecting content changes. Uses only Python's standard library (urllib) — no requests, no aiohttp, no external packages.
Features
- Uptime checking: Verify any URL returns the expected HTTP status code
- Response time measurement: Precise millisecond timing for each request
- Content change detection: SHA-256 based hashing to detect when page content changes between checks
- Text verification: Confirm that specific text appears in the response body
- Multi-URL support: Check multiple sites in a single command
- JSON output: Machine-readable output for integration with other tools and dashboards
- Exit codes: Returns exit code 1 if any site is down, making it perfect for shell scripts and cron jobs
Usage Examples
Simple uptime check:
python main.py https://example.com
# ✅ https://example.com
# Status: 200
# Response: 142ms
# Size: 1256 bytes
# Hash: fb91d75a6bb43078
Check multiple sites at once:
python main.py example.com google.com github.com
Detect content changes (compare against a previous hash):
python main.py https://example.com --hash-check fb91d75a6bb43078
# Shows "Changed: YES ⚠️" or "Changed: No"
Verify a page contains expected text:
python main.py https://status.example.com --contains "All Systems Operational"
Expect a specific status code (e.g., redirect):
python main.py https://old.example.com --expect 301
JSON output for scripting:
python main.py example.com github.com --json | jq '.[] | select(.up == false)'
Use in a cron job or script:
python main.py https://mysite.com || echo "ALERT: Site is down!" | mail -s "Downtime Alert" admin@example.com
Command Line Options
urls — One or more URLs to check (auto-prepends https:// if missing)
--timeout N — Request timeout in seconds (default: 10)
--expect N — Expected HTTP status code (default: 200)
--contains TEXT — Verify response body contains this string
--hash-check HASH — Previous content hash to compare against for change detection
--json — Output results as JSON array
Exit Codes
0 — All sites are up and match expectations
1 — One or more sites are down or failed checks
urls — One or more URLs to check (auto-prepends https:// if missing)--timeout N — Request timeout in seconds (default: 10)--expect N — Expected HTTP status code (default: 200)--contains TEXT — Verify response body contains this string--hash-check HASH — Previous content hash to compare against for change detection--json — Output results as JSON array0— All sites are up and match expectations1— One or more sites are down or failed checks
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。