Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep bounded process readers at the collector's privilege

pulse-triage[bot]5b15a6f94643
diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md
index a38b28874e..13a4e3758b 100644
--- a/docs/TROUBLESHOOTING.md
+++ b/docs/TROUBLESHOOTING.md
@@ -510,9 +510,10 @@ For a responsive **Linux systemd / Proxmox LXC** install, the following reads
two process-I/O samples, waiting 60 seconds between them. Run it inside the
Pulse container for LXC, not on the Proxmox host. Substitute the actual service
name (`pulse-backend` on some older installs) in both `systemctl` calls. Use an
-account authorised to read the process counters; `sudo -n` must already allow
-this read without prompting. Do not change privileges to make it pass; no
-service restart or database access is needed.
+account already permitted to read the process counters. The collector does not
+elevate privileges or prompt: an unprivileged deadline cannot reliably stop a
+privileged reader. If access is denied, stop rather than changing privileges
+to make it pass; no service restart or database access is needed.
```bash
# systemd / Proxmox LXC: bounded process-write samples
@@ -536,7 +537,7 @@ read_sample() {
END { if (found != 1) exit 1 }
' "/proc/$pid/stat")
timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- counters=$(sudo -n awk '
+ counters=$(awk '
$1 == "write_bytes:" || $1 == "cancelled_write_bytes:" {
if (NF != 2 || $2 !~ /^[0-9]+$/ || seen[$1]++) exit 1
print; fields++
diff --git a/frontend-modern/public/docs/TROUBLESHOOTING.md b/frontend-modern/public/docs/TROUBLESHOOTING.md
index a38b28874e..13a4e3758b 100644
--- a/frontend-modern/public/docs/TROUBLESHOOTING.md
+++ b/frontend-modern/public/docs/TROUBLESHOOTING.md
@@ -510,9 +510,10 @@ For a responsive **Linux systemd / Proxmox LXC** install, the following reads
two process-I/O samples, waiting 60 seconds between them. Run it inside the
Pulse container for LXC, not on the Proxmox host. Substitute the actual service
name (`pulse-backend` on some older installs) in both `systemctl` calls. Use an
-account authorised to read the process counters; `sudo -n` must already allow
-this read without prompting. Do not change privileges to make it pass; no
-service restart or database access is needed.
+account already permitted to read the process counters. The collector does not
+elevate privileges or prompt: an unprivileged deadline cannot reliably stop a
+privileged reader. If access is denied, stop rather than changing privileges
+to make it pass; no service restart or database access is needed.
```bash
# systemd / Proxmox LXC: bounded process-write samples
@@ -536,7 +537,7 @@ read_sample() {
END { if (found != 1) exit 1 }
' "/proc/$pid/stat")
timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- counters=$(sudo -n awk '
+ counters=$(awk '
$1 == "write_bytes:" || $1 == "cancelled_write_bytes:" {
if (NF != 2 || $2 !~ /^[0-9]+$/ || seen[$1]++) exit 1
print; fields++
diff --git a/scripts/tests/test_performance_troubleshooting_docs.py b/scripts/tests/test_performance_troubleshooting_docs.py
index a4e3b6d41e..96c4b523bb 100644
--- a/scripts/tests/test_performance_troubleshooting_docs.py
+++ b/scripts/tests/test_performance_troubleshooting_docs.py
@@ -72,11 +72,19 @@ elif name == 'ps':
print(os.environ.get(f'PROCESS_{count}', '4321 Sat Oct 3 00:00:00 2026'))
sys.exit(int(os.environ.get('PS_EXIT', '0')))
elif name == 'awk':
- assert args[-1] == '/proc/4321/stat'
- # comm may contain spaces and right parentheses. Starttime is field 22.
- ticks = os.environ.get(f'TICKS_{count}', '10000')
- fixture = root / f'stat-{count}'
- fixture.write_text('4321 (private ) worker) S ' + ' '.join(['0'] * 18 + [ticks]) + '\\n')
+ if args[-1] == '/proc/4321/io':
+ index = sum(call['name'] == name and call['args'][-1] == args[-1] for call in previous)
+ fixture = root / ('missing' if os.environ.get('IO_MISSING') else f'io-{index}')
+ else:
+ assert args[-1] == '/proc/4321/stat'
+ index = sum(call['name'] == name and call['args'][-1] == args[-1] for call in previous)
+ # comm may contain spaces and right parentheses. Starttime is field 22.
+ ticks = os.environ.get(f'TICKS_{index}', '10000')
+ fixture = root / f'stat-{index}'
+ fixture.write_text('4321 (private ) worker) S ' + ' '.join(['0'] * 18 + [ticks]) + '\\n')
+ if os.environ.get('AWK_EXIT'):
+ print('private permission error', file=sys.stderr)
+ sys.exit(int(os.environ['AWK_EXIT']))
sys.exit(subprocess.run([os.environ['REAL_AWK'], *args[:-1], str(fixture)]).returncode)
elif name == 'sudo':
assert args[0] in ('awk', '-n')
@@ -173,9 +181,11 @@ class PerformanceTroubleshootingDocsTest(unittest.TestCase):
result, calls = self.exercise("systemd")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual([c["name"] for c in calls],
- ["systemctl", "ps", "awk", "date", "sudo", "systemctl", "ps", "awk",
- "sleep", "systemctl", "ps", "awk", "date", "sudo", "systemctl", "ps", "awk"])
- self.assertEqual([c["args"][0:2] for c in calls if c["name"] == "sudo"], [["-n", "awk"]] * 2)
+ ["systemctl", "ps", "awk", "date", "awk", "systemctl", "ps", "awk",
+ "sleep", "systemctl", "ps", "awk", "date", "awk", "systemctl", "ps", "awk"])
+ self.assertFalse(any(c["name"] == "sudo" for c in calls))
+ self.assertEqual([c["args"][-1] for c in calls if c["name"] == "awk"],
+ ["/proc/4321/stat", "/proc/4321/io", "/proc/4321/stat"] * 2)
for value in (PROCESS_IDENTITY, "start ticks=10000", "write_bytes: 1000",
"write_bytes: 13000", "cancelled_write_bytes: 20", "cancelled_write_bytes: 30"):
self.assertIn(value, result.stdout)
@@ -191,7 +201,7 @@ class PerformanceTroubleshootingDocsTest(unittest.TestCase):
def test_failed_or_empty_identity_does_not_publish_counters(self):
for settings in ({"SYSTEMCTL_EXIT": "3"}, {"PS_EXIT": "4"}, {"PROCESS_0": ""},
- {"TICKS_0": ""}, {"TICKS_0": "bad"}, {"IO_MISSING": "1"}, {"SUDO_EXIT": "5"}):
+ {"TICKS_0": ""}, {"TICKS_0": "bad"}, {"IO_MISSING": "1"}, {"AWK_EXIT": "5"}):
with self.subTest(settings=settings):
result, calls = self.exercise("systemd", **settings)
self.assert_unavailable(result)
@@ -307,10 +317,10 @@ class PerformanceTroubleshootingDocsTest(unittest.TestCase):
"not bytes per second", "not a recent sampling window", "different scopes",
"inside the Pulse container", "does not make that data a clean", "Do not enable Debug",
"remove database indexes", "tmpfs", "Do not post databases", "manually redacted error",
- "no partial identity", "no unbounded fallback", "full container ID", "sudo -n"):
+ "no partial identity", "no unbounded fallback", "full container ID", "does not elevate privileges"):
self.assertIn(phrase, guide)
for copied in recipes().values():
- self.assertNotRegex(copied, r"\b(?:restart|rm|truncate|sqlite3|curl|printenv)\b|--follow|--token|(?:^|[;\n])\s*kill\b")
+ self.assertNotRegex(copied, r"\b(?:sudo|restart|rm|truncate|sqlite3|curl|printenv)\b|--follow|--token|(?:^|[;\n])\s*kill\b")
if __name__ == "__main__":