diff --git a/backend/requirements.txt b/backend/requirements.txt index afa7d15..0214abc 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -2,7 +2,7 @@ flask==3.0.0 flask-cors==4.0.0 flask-socketio==5.3.6 paramiko==3.4.0 -anthropic==0.39.0 +anthropic>=0.40.0 requests==2.31.0 python-dotenv==1.0.0 gevent==23.9.1 diff --git a/backend/services/claude_agent.py b/backend/services/claude_agent.py index 0694215..a83c19c 100644 --- a/backend/services/claude_agent.py +++ b/backend/services/claude_agent.py @@ -43,12 +43,13 @@ Always respond with valid JSON in this structure: "analysis": "Your analysis of what you found on the host", "monitors": [ { - "type": "http|tcp|ping|docker|keyword", + "type": "http|tcp|ping|docker|keyword|push", "name": "Human-readable monitor name", - "target": "URL, hostname, or container name", + "target": "URL, hostname, container name, or metric type for push", "port": 80, "interval": 60, - "reason": "Why this should be monitored" + "reason": "Why this should be monitored", + "push_metric": "disk|memory|cpu|updates (only for push type)" } ], "additional_commands": [ @@ -66,6 +67,31 @@ Always respond with valid JSON in this structure: - **ping**: Host availability (provide hostname) - **docker**: Docker container status (provide container name) - **keyword**: Check for specific text in response (provide URL and keyword) +- **push**: Push-based monitors for system metrics (scripts on host push to Uptime Kuma) + +## Push Monitors for System Metrics +Always suggest push monitors for system health metrics. These run as cron jobs on the host and push status to Uptime Kuma. Suggest these based on what you see: + +1. **Disk Space** - Alert when any partition exceeds 85% usage + - Name: "{hostname} - Disk Space" + - push_metric: "disk" + +2. **Memory Usage** - Alert when RAM exceeds 90% usage + - Name: "{hostname} - Memory" + - push_metric: "memory" + +3. **CPU Load** - Alert when load average exceeds CPU count + - Name: "{hostname} - CPU Load" + - push_metric: "cpu" + +4. **System Updates** - Alert when security updates are pending (Debian/Ubuntu) + - Name: "{hostname} - Updates" + - push_metric: "updates" + +For push monitors, set: +- type: "push" +- target: the metric type (disk, memory, cpu, updates) +- interval: 300 (5 minutes is typical for system metrics) Be thorough but not excessive. Quality over quantity - suggest monitors that will actually catch real problems.""" @@ -81,6 +107,7 @@ class MonitorSuggestion: interval: int = 60 reason: str = "" keyword: Optional[str] = None + push_metric: Optional[str] = None @dataclass @@ -234,6 +261,7 @@ Respond with JSON as specified in your instructions.""" interval=m.get("interval", 60), reason=m.get("reason", ""), keyword=m.get("keyword"), + push_metric=m.get("push_metric"), ) )