61 lines
1.6 KiB
Markdown
61 lines
1.6 KiB
Markdown
# Log Monitor Skill
|
|
|
|
Automatic log scanning and error repair for OpenClaw/agent systems.
|
|
|
|
## Purpose
|
|
|
|
Runs daily at 2 AM to:
|
|
1. Scan system logs (journald, cron, OpenClaw) for errors
|
|
2. Attempt safe auto-fixes for known issues
|
|
3. Report unhandled errors needing human attention
|
|
|
|
## Auto-Fixes Supported
|
|
|
|
| Error Pattern | Fix Action |
|
|
|---------------|------------|
|
|
| Missing Python module (`ModuleNotFoundError`) | `pip install <module>` |
|
|
| Permission denied on temp files | `chmod 755 <path>` |
|
|
| Ollama connection issues | `systemctl restart ollama` |
|
|
| Disk full | Alert only (requires manual cleanup) |
|
|
| Service down (connection refused) | Alert only (investigate first) |
|
|
|
|
## Usage
|
|
|
|
### Manual Run
|
|
```bash
|
|
cd /root/.openclaw/workspace/skills/log-monitor/scripts
|
|
python3 log_monitor.py
|
|
```
|
|
|
|
### View Latest Report
|
|
```bash
|
|
cat /tmp/log_monitor_report.txt
|
|
```
|
|
|
|
### Cron Schedule
|
|
Runs daily at 2:00 AM via `openclaw cron`.
|
|
|
|
## Adding New Auto-Fixes
|
|
|
|
Edit `log_monitor.py` and add to `AUTO_FIXES` dictionary:
|
|
|
|
```python
|
|
AUTO_FIXES = {
|
|
r"your-regex-pattern-here": {
|
|
"fix_cmd": "command-to-run {placeholder}",
|
|
"description": "Human-readable description with {placeholder}"
|
|
},
|
|
}
|
|
```
|
|
|
|
Use `{module}`, `{path}`, `{port}`, `{service}` as capture group placeholders.
|
|
|
|
Set `"alert": True` for issues that should notify you but not auto-fix.
|
|
|
|
## Safety
|
|
|
|
- Only "safe" fixes are automated (package installs, restarts, permissions)
|
|
- Critical issues (disk full, service down) alert but don't auto-fix
|
|
- All actions are logged to `/tmp/log_monitor_report.txt`
|
|
- Cron exits with code 1 if human attention needed (triggers notification)
|