mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-14 18:56:52 +00:00
ProxMenux modifies the host: it rewrites configuration files, installs packages, enables services. Until now nobody could say afterwards what had changed, and showing the script does not answer that question — a four-hundred-line function may alter two values, and the reader has no way to know which two. This adds the two halves of an answer. The change journal records what ProxMenux does as it does it. Eleven bash primitives capture the previous state, apply the change and record it in the same step, writing to a spool that the Monitor reads back. One hundred and thirteen functions across twenty-five scripts are instrumented, covering post-install, shared storage, security tooling, container conversions, disk operations and the PVE 8 to 9 upgrade path. The page shows the difference — rotate 7 becoming rotate 14 — and never the script. Restore and backup scripts are deliberately left out: a restore puts the host back to a state some other script already recorded. The Audit and reports page answers the other half: what state is this host in, regardless of who put it there. Forty-three checks across seven areas read the host and classify each result as critical, warning, observation, conformant, unverified or not applicable, with the evidence they read attached to each one. A declared policy lets the reader say what this particular host is expected to do — which guests must have a backup, which storages are essential — so the report judges the host against its own intent rather than a generic template. An inventory records the hardware, network and guest topology behind those readings, a comparison shows what moved between two runs, and six report profiles produce a printable document scoped to what the reader needs. Everything is available in the eight supported languages. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
87 lines
3.1 KiB
Python
87 lines
3.1 KiB
Python
import json
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from queue import Empty, Queue
|
|
|
|
|
|
SCRIPTS_DIR = Path(__file__).resolve().parents[1]
|
|
APPIMAGE_DIR = SCRIPTS_DIR.parent
|
|
if str(SCRIPTS_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SCRIPTS_DIR))
|
|
|
|
import notification_events # noqa: E402
|
|
import notification_templates # noqa: E402
|
|
|
|
|
|
class KernelTraceNotificationTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.queue = Queue()
|
|
self.watcher = notification_events.JournalWatcher(self.queue)
|
|
|
|
def _check(self, message, *, syslog_id="kernel", transport="kernel"):
|
|
self.watcher._check_kernel_critical(
|
|
message,
|
|
syslog_id,
|
|
4,
|
|
{
|
|
"_TRANSPORT": transport,
|
|
"__REALTIME_TIMESTAMP": "1788883200000000",
|
|
},
|
|
)
|
|
|
|
def test_bare_call_trace_is_not_an_event(self):
|
|
self._check("Call Trace:")
|
|
with self.assertRaises(Empty):
|
|
self.queue.get_nowait()
|
|
|
|
def test_kernel_warning_carries_attributable_fields(self):
|
|
self._check(
|
|
"WARNING: CPU: 2 PID: 418 Comm: z_wr_iss at arc_evict_state+0x12/0x80"
|
|
)
|
|
event = self.queue.get_nowait()
|
|
self.assertEqual(event.event_type, "kernel_warning")
|
|
self.assertEqual(event.severity, "WARNING")
|
|
self.assertIn("Type: Kernel warning", event.data["kernel_details"])
|
|
self.assertIn("Process: z_wr_iss (PID 418)", event.data["kernel_details"])
|
|
self.assertIn("Component: arc_evict_state", event.data["kernel_details"])
|
|
self.assertIn("Recorded: 2026-", event.data["kernel_details"])
|
|
self.assertIn("WARNING: CPU", event.data["_journal_context"])
|
|
|
|
self._check("Call Trace:")
|
|
with self.assertRaises(Empty):
|
|
self.queue.get_nowait()
|
|
|
|
def test_application_text_cannot_impersonate_kernel_warning(self):
|
|
self._check(
|
|
"WARNING: CPU: 0 PID: 99 Comm: example at fake_function+0x1/0x2",
|
|
syslog_id="systemd",
|
|
transport="stdout",
|
|
)
|
|
with self.assertRaises(Empty):
|
|
self.queue.get_nowait()
|
|
|
|
def test_blocked_task_is_identified(self):
|
|
self._check("INFO: task txg_sync:812 blocked for more than 120 seconds.")
|
|
event = self.queue.get_nowait()
|
|
self.assertEqual(event.event_type, "kernel_warning")
|
|
self.assertIn("Type: Blocked kernel task", event.data["kernel_details"])
|
|
self.assertIn("Process: txg_sync", event.data["kernel_details"])
|
|
|
|
def test_event_is_visible_and_translated_in_every_monitor_locale(self):
|
|
services = notification_templates.get_event_types_by_group()["services"]
|
|
self.assertIn("kernel_warning", {item["type"] for item in services})
|
|
for locale in ("en", "es", "de", "fr", "it", "pt", "sk", "sv"):
|
|
messages = json.loads(
|
|
(APPIMAGE_DIR / "messages" / locale / "common.json").read_text(
|
|
encoding="utf-8"
|
|
)
|
|
)
|
|
self.assertTrue(
|
|
messages["settings"]["notifications"]["eventTypes"]["kernel_warning"]
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|