website-monitor
轻量级网站正常运行时间监视器。检查 URL 是否已启动、测量响应时间、通过哈希检测内容更改并验证预期内容。零依赖。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~claudiodrusus-website-monitorcURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~claudiodrusus-website-monitor/file -o claudiodrusus-website-monitor.md# 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: ```bash python main.py https://example.com # ✅ https://example.com # Status: 200 # Response: 142ms # Size: 1256 bytes # Hash: fb91d75a6bb43078 ``` Check multiple sites at once: ```bash python main.py example.com google.com github.com ``` Detect content changes (compare against a previous hash): ```bash python main.py https://example.com --hash-check fb91d75a6bb43078 # Shows "Changed: YES ⚠️" or "Changed: No" ``` Verify a page contains expected text: ```bash python main.py https://status.example.com --contains "All Systems Operational" ``` Expect a specific status code (e.g., redirect): ```bash python main.py https://old.example.com --expect 301 ``` JSON output for scripting: ```bash python main.py example.com github.com --json | jq '.[] | select(.up == false)' ``` Use in a cron job or script: ```bash 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 --- ## 中文说明 # Website Monitor 一个零依赖的 Python 工具,用于检查网站可用性、测量响应时间并检测内容变化。仅使用 Python 标准库(urllib)——无需 requests、aiohttp 或任何外部包。 ## 功能 - **正常运行时间检查**:验证任意 URL 是否返回预期的 HTTP 状态码 - **响应时间测量**:为每个请求提供精确到毫秒的计时 - **内容变化检测**:基于 SHA-256 的哈希,检测两次检查之间页面内容是否发生变化 - **文本验证**:确认响应正文中出现特定文本 - **多 URL 支持**:在单条命令中检查多个站点 - **JSON 输出**:机器可读的输出,便于与其他工具和仪表盘集成 - **退出码**:如果任何站点宕机则返回退出码 1,非常适合 shell 脚本和 cron 作业 ## 使用示例 简单的正常运行时间检查: ```bash python main.py https://example.com # ✅ https://example.com # Status: 200 # Response: 142ms # Size: 1256 bytes # Hash: fb91d75a6bb43078 ``` 一次性检查多个站点: ```bash python main.py example.com google.com github.com ``` 检测内容变化(与之前的哈希比较): ```bash python main.py https://example.com --hash-check fb91d75a6bb43078 # Shows "Changed: YES ⚠️" or "Changed: No" ``` 验证页面包含预期文本: ```bash python main.py https://status.example.com --contains "All Systems Operational" ``` 期望特定状态码(例如重定向): ```bash python main.py https://old.example.com --expect 301 ``` 用于脚本的 JSON 输出: ```bash python main.py example.com github.com --json | jq '.[] | select(.up == false)' ``` 在 cron 作业或脚本中使用: ```bash python main.py https://mysite.com || echo "ALERT: Site is down!" | mail -s "Downtime Alert" admin@example.com ``` ## 命令行选项 - `urls` — 要检查的一个或多个 URL(缺少时自动添加 https:// 前缀) - `--timeout N` — 请求超时秒数(默认:10) - `--expect N` — 期望的 HTTP 状态码(默认:200) - `--contains TEXT` — 验证响应正文包含此字符串 - `--hash-check HASH` — 用于变化检测的之前的内容哈希 - `--json` — 以 JSON 数组形式输出结果 ## 退出码 - `0` — 所有站点均正常且符合预期 - `1` — 一个或多个站点宕机或检查失败