Feature request: pstree color-by-xxx
Hi;
As a first step when debugging a system that's slowing down, I run 'pstree', and try to identify recently-started processes (e.g. crashing/restarting loop).
Today, I wrote a perl one-liner that color-codes the output of 'pstree -Tp' using the output of 'ps -eo pid,lstart':
pstree -Tp | perl -MTime::ParseDate -MTerm::ANSIColor -ne 'BEGIN{map {my ($aa,$bb)=$_=~m/(\d+) (\S.+)/; $age{$aa}=time()-parsedate($bb)} split (/\n/,`ps -eo pid,lstart`);}; s/[(]([0-9]+)[)]/"(".colored($1,!defined $age{$1}?"white":$age{$1}<=60?"green":$age{$1}<=3600?"yellow":"red").")"/ge;print'
It colors processes either green, yellow, or red for process ages that are "< 1 minute", "< 1 hour", or older, and I think it looks pretty cool.
Since pstree already reads from /proc//stat and does highlighting of processes, it wouldn't be a big stretch to add a heatmap feature for age, memory or cpu usage, would it?
Thanks in advance!