Skip to content

perf(os): run the system commands without a shell and with time limits - #1244

Open
karlitschek wants to merge 1 commit into
masterfrom
perf/command-timeouts
Open

karlitschek wants to merge 1 commit into
masterfrom
perf/command-timeouts

Conversation

@karlitschek

Copy link
Copy Markdown
Member

Based on feat/os-status-collector (#1214).

AI disclosure: this change was written with Claude Code (claude-opus-5-5) and is to be reviewed by the author before it leaves draft; every commit carries an Assisted-by trailer.

馃 Generated with Claude Code

@karlitschek
karlitschek force-pushed the feat/os-status-collector branch from 6d327c2 to 34014ec Compare October 25, 2026 19:19
Base automatically changed from feat/os-status-collector to master October 25, 2026 19:24
@karlitschek
karlitschek force-pushed the perf/command-timeouts branch from dfe6727 to 8806f53 Compare October 25, 2026 19:25
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Oct 25, 2026
The Linux and FreeBSD backends ran df, free, nproc, sysctl, swapinfo,
netstat, ifconfig, date and a cat of /proc/self/stat through shell_exec
with no time limit, and the gateway through the pipeline
`ip route | awk`. A stale NFS or CIFS mount makes df hang, so every
Status page load or diskdata call then held a PHP worker until FPM
killed it. On FreeBSD each poll also forked date(1) and sysctl twice
for values PHP already knows.

All commands now go through the OS status CommandRunner via IHost, in
a small CommandOutput helper: argument vectors, no shell, a fixed
PATH, the runner's output cap, 2 s per command and 5 s for df. Output
of a command that exits with an error is still used, as before, since
df does so when one mount point is unreadable. When df is stopped at
its limit, the complete lines it printed are still reported and one
warning is logged; other failures are logged at debug level.

- Linux: `ip route show default` is parsed in PHP; several default
  gateways are joined with ", " as on FreeBSD, and the value is always
  a string (shell_exec returned null without output).
- FreeBSD: the time is formatted in PHP in the zone /etc/localtime
  links to or /var/db/zoneinfo names; the boot time moves to
  sampleUptime(), so Os caches it as it does on Linux; hw.model and
  kern.smp.cpus come from one sysctl; ifconfig gets the interface as
  an argument and only names that are valid interface names; the load
  average comes from sys_getloadavg().

The tests run the backends against FakeHost instead of mocking
executeCommand, and cover timeouts, failed commands and the route
parser.

Assisted-by: ClaudeCode:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Frank Karlitschek <[email protected]>
@karlitschek
karlitschek force-pushed the perf/command-timeouts branch from 8806f53 to 9802b97 Compare October 25, 2026 19:45
@karlitschek
karlitschek marked this pull request as ready for review October 25, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants