監視とアラート / Monitoring & Alerting
- 日本語
- English
- 简体中文
🔔 「問題が起きたら即通知」を自動化する
OpenClawの自律エージェントは「巡回監視員」として非常に優秀です。サーバーの状態、ファイルの変更、特定のキーワードの出現などを自動的にチェックし、異常を検知したらDiscord/Slack/メールに即座に通知を飛ばすことができます。
監視パターン一覧
graph TD;
subgraph Patterns[監視パターン]
P1[🖥 サーバー死活監視]
P2[📄 ログファイル異常検知]
P3[🌐 WebサイトのHTTPステータス]
P4[📊 リソース使用率 (CPU/RAM)]
P5[🔐 認証ログの不正アクセス]
end
P1 --> Alert[🔔 アラート送信]
P2 --> Alert
P3 --> Alert
P4 --> Alert
P5 --> Alert
Alert --> Discord[💬 Discord]
Alert --> Slack[💬 Slack]
Alert --> Email[📧 メール]
パターン1: サーバーがダウンしていないか確認する
Cronジョブで毎5分おきに対象サーバーへのHTTPリクエストを投げ、レスポンスがなければ通知を送る。
依頼例
以下のURLに対して curl で HEAD リクエストを送ってください:
- https://example.com
- https://api.example.com/health
HTTP 200 以外のレスポンス、またはタイムアウトが発生した場合は
Discord Webhook で即座にアラートを送信してください。
全て正常な場合は何もしないでください。
パターン2: ログファイルの異常検知
依頼例
/var/log/auth.log の最新100行を読んで、
"Failed password" や "Invalid user" というキーワードが
5件以上含まれている場合は、不正アクセスの可能性ありとして
Discord にアラートを送信してください。
パターン3: ディスク容量の監視
依頼例
df -h コマンドを実行し、使用率が90%を超えているパーティションがあれば
Discord Webhook でアラートを送信してください。
レポート形式:
🚨 ディスク残量警告
パーティション:/dev/sda1
使用率:92%
残り容量:3.2GB
💡 アラート疲れを防ぐコツ
- 閾値を適切に設定する: 些細な変動に毎回通知が飛ぶと、重要なアラートを見落とします。
- 「正常時は何もしない」ルール: 「異常がない限り通知しないで」という指示を必ず含めてください。
- サマリー方式: 1時間分の異常を蓄積してから1件のメッセージにまとめて送る方法も効率的です。
🔔 Automate "Instant Notification When Something Goes Wrong"
An OpenClaw autonomous agent excels as a "patrol guard." It can automatically check server status, file changes, keyword appearances, and more—then instantly fire notifications to Discord/Slack/Email upon detecting anomalies.
Monitoring Pattern Overview
graph TD;
subgraph Patterns[Monitoring Patterns]
P1[🖥 Server Uptime]
P2[📄 Log File Anomalies]
P3[🌐 Website HTTP Status]
P4[📊 Resource Usage (CPU/RAM)]
P5[🔐 Auth Log Intrusion]
end
P1 --> Alert[🔔 Send Alert]
P2 --> Alert
P3 --> Alert
P4 --> Alert
P5 --> Alert
Alert --> Discord[💬 Discord]
Alert --> Slack[💬 Slack]
Alert --> Email[📧 Email]
Pattern 1: Server Uptime Check
Every 5 minutes via Cron, send an HTTP HEAD request to target servers. If no response, send a notification.
Prompt Example
Send a curl HEAD request to these URLs:
- https://example.com
- https://api.example.com/health
If any response is NOT HTTP 200, or a timeout occurs,
immediately send an alert via Discord Webhook.
If everything is normal, do nothing.
Pattern 2: Log File Anomaly Detection
Prompt Example
Read the latest 100 lines of /var/log/auth.log.
If keywords "Failed password" or "Invalid user" appear
5 or more times, send a Discord alert flagging
potential unauthorized access.
Pattern 3: Disk Usage Monitoring
Prompt Example
Run `df -h` and if any partition exceeds 90% usage,
send a Discord Webhook alert. Use this format:
🚨 Disk Space Warning
Partition: /dev/sda1
Usage: 92%
Remaining: 3.2GB
💡 Preventing Alert Fatigue
- Set appropriate thresholds: Notifications on every minor fluctuation cause important alerts to be overlooked.
- "Do nothing when normal" rule: Always include "Don't notify unless there's an anomaly" in your prompt.
- Batched summaries: Accumulate anomalies over an hour and send as one consolidated message.
🔔 自动化"出问题就立即通知"
OpenClaw 的自治代理非常擅长充当"巡逻卫士"。它可以自动检查服务器状态、文件变更、特定关键字的出现等,一旦检测到异常,立即向 Discord/Slack/邮箱发送通知。
监控模式概览
graph TD;
subgraph Patterns[监控模式]
P1[🖥 服务器存活检测]
P2[📄 日志文件异常检测]
P3[🌐 网站 HTTP 状态]
P4[📊 资源使用率 (CPU/RAM)]
P5[🔐 认证日志入侵检测]
end
P1 --> Alert[🔔 发送警报]
P2 --> Alert
P3 --> Alert
P4 --> Alert
P5 --> Alert
Alert --> Discord[💬 Discord]
Alert --> Slack[💬 Slack]
Alert --> Email[📧 邮件]
模式 1:服务器存活检测
通过 Cron 每 5 分钟向目标服务器发送 HTTP HEAD 请求。如果没有响应,则发送通知。
提示示例
请对以下 URL 发送 curl HEAD 请求:
- https://example.com
- https://api.example.com/health
如果任何响应不是 HTTP 200,或发生超时,
请立即通过 Discord Webhook 发送警报。
一切正常则什么都不做。
模式 2:日志文件异常检测
提示示例
读取 /var/log/auth.log 的最新 100 行。
如果关键词 "Failed password" 或 "Invalid user"
出现 5 次以上,请通过 Discord 发送警报,
标记存在潜在未授权访问的风险。
模式 3:磁盘空间监控
提示示例
执行 `df -h` 命令,如果任何分区使用率超过 90%,
通过 Discord Webhook 发送警报。使用以下格式:
🚨 磁盘空间警告
分区:/dev/sda1
使用率:92%
剩余空间:3.2GB
💡 防止警报疲劳
- 设置合理的阈值:每次微小波动都触发通知,会导致真正重要的警报被忽视。
- "正常时不通知"规则:始终在提示中包含"没有异常就不要通知我"的指令。
- 批量汇总方式:将一小时内的异常积累起来,合并为一条消息发送,效率更高。