Log Collector

Permanent log collection agent. Collects logs and history from all nodes via SSH/VPN every 3 hours. Stores in logs.db with 30-day retention. Multi-node capable with fallback logic.

Audits

Warn

Install

openclaw skills install log-collector

Log Collector Sub-Agent

Permanenter Log-Sammel-Agent für alle Nodes im Cluster.

Aufgaben

IntervallAufgabeDetails
3 StundenNode-AbfrageSSH über VPN zu allen Nodes
3 StundenLog-CollectionSystem-Logs, OpenClaw-Logs, VPN-Status
3 StundenDatenbank-UpdateSchreibt in logs.db
TäglichRetention-CleanupLöscht Logs > 30 Tage

Multi-Node Support

NodeVerbindungPriorität
Node 1 (Gateway)LokalPrimär (Sammel-Node)
Node 2 (Netcup)SSH → 10.10.0.2Abfrage-Ziel
Node 3 (xNetX)SSH → 10.10.0.3Abfrage-Ziel
Node 4+SSH → 10.10.0.XVariable Erreichbarkeit

VPN-Priorität

1. Tailscale (primär) → schneller, stabil
2. WireGuard (fallback) → zuverlässiger Tunnel
3. SSH WAN (letzter Fallback) → langsamster

Datenbank: logs.db

Tabellen

TabelleInhalt
nodesBekannte Nodes mit VPN-IP, SSH-Keys
logsGesammelte Logs (max. 30 Tage)
ssh_connectionsVerbindungs-Log (Erfolg/Fehler)
vpn_statusTailscale/WireGuard Status
collection_runsAbfrage-Tracking pro Durchlauf
node_logs_rawRoh-Logs unverarbeitet

Retention

-- Automatisch: Logs > 30 Tage löschen
DELETE FROM logs WHERE retention_until < datetime('now');

Abfrage-Workflow

# Für jeden Node in nodes-Tabelle:
for node in nodes:
    # 1. VPN-Status prüfen
    vpn_status = check_vpn(node.tailscale_ip) or \
                 check_vpn(node.wireguard_ip)
    
    # 2. SSH-Verbindung versuchen
    if ssh_connect(node.ssh_key_path, node.vpn_ip):
        # 3. Logs abholen
        logs = ssh_exec('journalctl -n 1000')
        
        # 4. In logs.db speichern
        insert_logs(node.node_id, logs)
    else:
        # 5. Fehler loggen
        insert_ssh_error(node.node_id, "Connection failed")

Variable Erreichbarkeit

SzenarioVerhalten
Node immer erreichbarNormale Abfrage, vollständige Logs
Node manchmal erreichbarBest-effort, sammelt wenn möglich
Node nie erreichbarWird trotzdem versucht, Fehler geloggt
Gateway offlineLokale Buffer, später Übertragung

Berechtigungen

exec: read_write_ssh
nodes: query_all
logs: collect_store
retention: cleanup_30d

Konfiguration

{
  "log-collector": {
    "enabled": true,
    "collection_interval_hours": 3,
    "retention_days": 30,
    "nodes": [
      {"id": "node1", "local": true},
      {"id": "node2", "ssh_key": "~/.ssh/node2_key"},
      {"id": "node3", "ssh_key": "~/.ssh/node3_key"},
      {"id": "node4", "ssh_key": "~/.ssh/node4_key", "optional": true}
    ],
    "vpn_priority": ["tailscale", "wireguard", "wan"]
  }
}

Scripts

ScriptZweck
log_collector.pyHaupt-Collection-Logik
ssh_connector.pySSH-Verbindungen mit Fallback
vpn_checker.pyVPN-Status-Prüfung
retention_cleanup.py30-Tage Cleanup

Logs

logs/log-collector/
├── 2026-04-18.log
├── collection-errors.log
└── run-summary.json

Installation

# Skill installieren
clawhub install log-collector

# Cron aktivieren (alle 3 Stunden)
0 */3 * * * /usr/bin/python3 /home/openclaw/.openclaw/workspace/skills/log-collector/scripts/log_collector.py

Troubleshooting

Problem: SSH-Verbindung fehlgeschlagen

Prüfung:

# VPN erreichbar?
ping 10.10.0.2

# SSH-Key korrekt?
ssh -i ~/.ssh/node2_key openclaw@10.10.0.2

Problem: Logs nicht in Datenbank

Prüfung:

# logs.db existiert?
ls -la db/logs.db

# Fehler-Log
tail logs/log-collector/collection-errors.log

Integration

  • db-maintainer: Separate DB, gleiche Backup-Strategie
  • workspace-db: Dokumentations-Index (separat)
  • tree.db v2: Datei-Tracking (separat)

Hinweis: Konfiguration (SSH-Keys, IPs) nicht im Skill - muss in env/db konfiguriert werden.