Skip to content

Commit 3161fb0

Browse files
Mark Shroyerfacebook-github-bot
authored andcommitted
Include top in eden rage
Summary: There have been support requests where we needed to rule out high system load on the user's computer (rather than EdenFS) slowing down their experience. This adds a snapshot of `top` to the output of `eden rage` on Linux and macOS so we don't have to ask the user for this. We only include the top ten-ish processes in the output to avoid blowing up the `rage`. Reviewed By: chadaustin Differential Revision: D41351716 fbshipit-source-id: 5db170b1b83ff58ffce21769b379e9ad2b38738a
1 parent ed07932 commit 3161fb0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

eden/fs/cli/rage.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ def print_diagnostic_info(
218218

219219
print_system_mount_table(out)
220220

221+
print_system_load(out)
222+
221223

222224
def report_edenfs_bug(instance: EdenInstance, reporter: str) -> None:
223225
rage_lambda: Callable[
@@ -468,6 +470,32 @@ def print_system_mount_table(out: IO[bytes]) -> None:
468470
out.write(f"Error printing system mount table: {e}\n".encode())
469471

470472

473+
def print_system_load(out: IO[bytes]) -> None:
474+
if sys.platform not in ("darwin", "linux"):
475+
return
476+
477+
try:
478+
section_title("System load:", out)
479+
if sys.platform == "linux":
480+
output = subprocess.check_output(["top", "-b", "-n1"])
481+
482+
# Limit to the first 16 lines of output because top on CentOS
483+
# doesn't seem to have a command-line flag for this.
484+
output_lines = output.decode("utf-8").split(os.linesep)[:17]
485+
elif sys.platform == "darwin":
486+
output = subprocess.check_output(["top", "-l2", "-n10"])
487+
488+
# On macOS the first iteration of `top` will have incorrect CPU
489+
# usage values for processes. So here we wait for the second
490+
# iteration and strip the first from the output.
491+
output_lines = output.decode("utf-8").split(os.linesep)
492+
output_lines = output_lines[len(output_lines) // 2 :]
493+
494+
out.write(os.linesep.join(output_lines).encode("utf-8"))
495+
except Exception as e:
496+
out.write(f"Error printing system load: {e}\n".encode())
497+
498+
471499
def print_eden_config(instance: EdenInstance, out: IO[bytes]) -> None:
472500
try:
473501
section_title("EdenFS config:", out)

0 commit comments

Comments
 (0)