0

Using htop and its tree view (trigger by t or F5) one can see processes by parenthood, and layout the relations between them as a tree.

Is there a way to see how the process tree evolves in slow motion? That is, record the history somehow and play it back at a custom speed, a bit like a video player that allows stepping through frame by frame? Right now, it sometimes flashes by too fast to keep track of.

Alternative tools to htop are welcome too.

1
  • 1
    I know atop can be configured to log system events and play them back, I don't know if it can be set up to achieve what you want though.
    – Mokubai
    Aug 2, 2022 at 9:39

1 Answer 1

2

Limited generic way to replay in slow motion

You can use script to record htop, like:

script -O typescript -T typescript.timing -c 'htop -t'

script will exit just after htop exits. Alternatively:

script -O typescript -T typescript.timing

puts you in a shell where you can run htop -t and/or whatever. In this method it's important to exit the shell; only then script exits.

After script exits, you can replay in slow motion:

scriptreplay typescript.timing typescript 0.1

Limitations:

  • script records what happens in a terminal session. In your case it does not really record the process tree. It records what htop prints and it so happens it prints the tree. But if htop does not show you some process (because it's transient or you're just scrolling through the wrong part of the tree) then scriptreplay won't show the process either. Consider htop -t -d 1 to make transient processes more likely to be seen. Anyway script+htop is by no means a reliable way to audit processes in your OS. I mean you can and will miss out on some processes.

  • What happens in a terminal session depends on the size of the terminal. Playing it back in a terminal of a different size (especially if smaller in any direction) may cause misalignments, artifacts and such. Resizing the terminal during playback may cause additional artifacts.

  • If you interrupt scriptreplay with Ctrl+c then you may need to run reset or in another way bring your terminal to a sane state.

  • AFAIK scriptreplay is not interactive, one cannot even pause it. I have found scriptreplay_ng, it seems somewhat better in this aspect; but I haven't tested.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .