Auftragsbuch: 'wartung/parse-mc2-timeout-user-journal' angenommen (Ein-Klick-Gate)

This commit is contained in:
Auftragsbuch
2026-07-16 11:01:48 +02:00
+6 -3
View File
@@ -6,6 +6,8 @@ Captures lines containing "State 'stop-sigterm' timed out" and appends them
to ~/logs/mc2-timeout.log with ISO timestamps.
Permission errors are handled gracefully.
Uses user journal (systemctl --user) to query logs.
"""
import os
@@ -27,9 +29,10 @@ def ensure_log_dir() -> None:
def get_timeout_entries() -> list[str]:
"""Run journalctl and return lines matching the timeout pattern."""
"""Run journalctl --user and return lines matching the timeout pattern."""
cmd = [
"journalctl",
"--user",
"-u", SERVICE_NAME,
"--no-pager",
"-n", str(JOURNALCTL_LIMIT),
@@ -45,12 +48,12 @@ def get_timeout_entries() -> list[str]:
print("journalctl timed out")
return []
except PermissionError:
print("Permission denied: journalctl requires access to system logs")
print("Permission denied: journalctl requires access to user logs")
return []
if result.returncode != 0:
if "Permission denied" in result.stderr:
print("Permission denied: journalctl requires access to system logs")
print("Permission denied: journalctl requires access to user logs")
else:
print(f"journalctl failed: {result.stderr.strip()}")
return []