Skip to content

Commit

Permalink
Include top in eden rage
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mark Shroyer authored and facebook-github-bot committed Nov 16, 2022
1 parent ed07932 commit 3161fb0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions eden/fs/cli/rage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3161fb0

Please sign in to comment.