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
This commit is contained in:
Mark Shroyer 2022-11-16 13:47:13 -08:00 committed by Facebook GitHub Bot
parent ed07932441
commit 3161fb08ff

View File

@ -218,6 +218,8 @@ def print_diagnostic_info(
print_system_mount_table(out)
print_system_load(out)
def report_edenfs_bug(instance: EdenInstance, reporter: str) -> None:
rage_lambda: Callable[
@ -468,6 +470,32 @@ def print_system_mount_table(out: IO[bytes]) -> None:
out.write(f"Error printing system mount table: {e}\n".encode())
def print_system_load(out: IO[bytes]) -> None:
if sys.platform not in ("darwin", "linux"):
return
try:
section_title("System load:", out)
if sys.platform == "linux":
output = subprocess.check_output(["top", "-b", "-n1"])
# Limit to the first 16 lines of output because top on CentOS
# doesn't seem to have a command-line flag for this.
output_lines = output.decode("utf-8").split(os.linesep)[:17]
elif sys.platform == "darwin":
output = subprocess.check_output(["top", "-l2", "-n10"])
# On macOS the first iteration of `top` will have incorrect CPU
# usage values for processes. So here we wait for the second
# iteration and strip the first from the output.
output_lines = output.decode("utf-8").split(os.linesep)
output_lines = output_lines[len(output_lines) // 2 :]
out.write(os.linesep.join(output_lines).encode("utf-8"))
except Exception as e:
out.write(f"Error printing system load: {e}\n".encode())
def print_eden_config(instance: EdenInstance, out: IO[bytes]) -> None:
try:
section_title("EdenFS config:", out)