fix: parse_mc2_timeout.py auf User-Journal umstellen (--user)

This commit is contained in:
werkstatt
2026-07-16 11:00:33 +02:00
parent fd241aca51
commit d697f3cc0d
+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. to ~/logs/mc2-timeout.log with ISO timestamps.
Permission errors are handled gracefully. Permission errors are handled gracefully.
Uses user journal (systemctl --user) to query logs.
""" """
import os import os
@@ -27,9 +29,10 @@ def ensure_log_dir() -> None:
def get_timeout_entries() -> list[str]: 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 = [ cmd = [
"journalctl", "journalctl",
"--user",
"-u", SERVICE_NAME, "-u", SERVICE_NAME,
"--no-pager", "--no-pager",
"-n", str(JOURNALCTL_LIMIT), "-n", str(JOURNALCTL_LIMIT),
@@ -45,12 +48,12 @@ def get_timeout_entries() -> list[str]:
print("journalctl timed out") print("journalctl timed out")
return [] return []
except PermissionError: except PermissionError:
print("Permission denied: journalctl requires access to system logs") print("Permission denied: journalctl requires access to user logs")
return [] return []
if result.returncode != 0: if result.returncode != 0:
if "Permission denied" in result.stderr: 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: else:
print(f"journalctl failed: {result.stderr.strip()}") print(f"journalctl failed: {result.stderr.strip()}")
return [] return []