feat: collecte automatique des logs locaux au début de chaque créneau

- _collect_local_logs() appelle journalctl en local au démarrage du slot
- collect_local_logs(since=) accessible comme méthode publique
- Skill logwatch collect [since] pour collecte manuelle à la demande
- Config: local_log_since, local_log_units, local_hostname

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 09:07:27 +00:00
parent bdcfff9f8e
commit c039b92d6d
6 changed files with 81 additions and 1 deletions
Binary file not shown.
+8 -1
View File
@@ -17,7 +17,7 @@ Usage LLM :
import threading
from datetime import datetime, timedelta
DESCRIPTION = "Contrôle LogWatch : schedule, analyse à la demande, statut, logs en attente"
DESCRIPTION = "Contrôle LogWatch : schedule, analyse à la demande, statut, logs en attente, collecte locale"
USAGE = (
"SKILL:logwatch ARGS:status\n"
"SKILL:logwatch ARGS:schedule show\n"
@@ -26,6 +26,7 @@ USAGE = (
"SKILL:logwatch ARGS:overage <minutes>\n"
"SKILL:logwatch ARGS:analyze <hostname>\n"
"SKILL:logwatch ARGS:analyze_all\n"
"SKILL:logwatch ARGS:collect [since]\n"
"SKILL:logwatch ARGS:retention <jours>\n"
"SKILL:logwatch ARGS:logs <hostname> [N]\n"
"SKILL:logwatch ARGS:reset <hostname>"
@@ -239,6 +240,12 @@ def run(args: str, context) -> str:
)
return "\n".join(lines)
# ── collect [since] ───────────────────────────────────────────────────────
if action == 'collect':
since = rest.strip() or 'yesterday'
result = context.agent.collect_local_logs(since=since)
return f"✅ Collecte locale terminée:\n{result}"
# ── reset <hostname> ──────────────────────────────────────────────────────
if action == 'reset':
hostname = rest.strip()