Report services needing a restart via a separate root needrestart unit
needrestart has to inspect every process, which an unprivileged agent can't (and unprivileged it gave false kernel results). Add kernelwatch-needrestart.service: root with only CAP_SYS_PTRACE and CAP_DAC_READ_SEARCH, PrivateNetwork=yes, list-only (-r l). It writes `needrestart -b` output to /run/kernelwatch/needrestart; the agent unit pulls it in before each report and reads the file (ignored if older than 2h). The agent no longer runs needrestart itself. Skipped cleanly when needrestart isn't installed: the dashboard shows "?" and status is unaffected. Server: services_need_restart / sessions_need_restart fields, an "update"-level reason, a Services column, and a note (not an escalation) for hosts running an agent older than the one shipped with the server. install.sh --with-needrestart installs needrestart and sets it to list services after apt upgrades instead of prompting; deploy.sh passes anything after `--` to install.sh. Agent 0.2.0, server 0.2.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
69d4cf6363
commit
834c1459c0
14 files changed
+258
-26
No files matched your search
@@ -57,7 +57,7 @@ class DeployTest(unittest.TestCase):
|
||||
os.makedirs(d)
|
||||
|
||||
for name in ("deploy.sh", "kernelwatch-agent", "kernelwatch-agent.service",
|
||||
"kernelwatch-agent.timer"):
|
||||
"kernelwatch-agent.timer", "kernelwatch-needrestart.service"):
|
||||
shutil.copy2(os.path.join(AGENT_DIR, name), self.agent)
|
||||
write_exec(os.path.join(self.agent, "install.sh"), FAKE_INSTALL)
|
||||
|
||||
@@ -145,6 +145,11 @@ class DeployTest(unittest.TestCase):
|
||||
self.assertNotIn("admin@dash", f.read(), "upgrades don't touch the dashboard")
|
||||
self.assert_clean()
|
||||
|
||||
def test_install_args_passed_through(self):
|
||||
proc = self.deploy("web01.example.test", "--", "--with-needrestart")
|
||||
self.assertEqual(proc.returncode, 0, proc.stderr)
|
||||
self.assertEqual(self.installed("web01.example.test")[0], ["--with-needrestart"])
|
||||
|
||||
def test_register_existing_fails_but_others_continue(self):
|
||||
self.assertEqual(self.deploy("--register", "web01.example.test").returncode, 0)
|
||||
proc = self.deploy("--register", "web01.example.test", "new01.example.test")
|
||||
|
||||
Reference in new issue
Block a user