Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps alternative to "who eats memory" #51

Open
abitrolly opened this issue Feb 3, 2022 · 2 comments
Open

ps alternative to "who eats memory" #51

abitrolly opened this issue Feb 3, 2022 · 2 comments

Comments

@abitrolly
Copy link
Member

Problems with ps.

  • default output is not useful
~ ps
    PID TTY          TIME CMD
 487827 pts/4    00:00:00 zsh
 495775 pts/4    00:00:00 ps
ps afu | awk 'NR>1 {$5=int($5/1024)"M";}{ print;}'
  • no colors to help you digest the info

Draft of the ideal solution.

root@a36a405677a1:/var/log# ps faux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     2992289  0.0  0.0   4240  3448 pts/0    Ss   19:59   0:00 /bin/bash
root     2995029  0.0  0.0   5896  2896 pts/0    R+   20:11   0:00  \_ ps faux
root           1  0.0  0.0   1104    40 ?        Ss   Jan11   0:26 /sbin/docker-init -- /usr/local/bin/my_init
root           6  0.0  0.1  20656  4792 ?        S    Jan11   0:00 /usr/bin/python3 -u /usr/local/bin/my_init
root          17  0.0  0.0   2524    88 ?        S    Jan11   0:10  \_ /usr/bin/runsvdir -P /etc/service
root          18  0.0  0.0   2372    72 ?        Ss   Jan11   0:00      \_ runsv supervisord
root          20  0.0  0.0   2608    68 ?        S    Jan11   0:00      |   \_ /bin/sh ./run
root          22  0.0  0.4  34700 16832 ?        S    Jan11   9:53      |       \_ /usr/bin/python3 /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
azuraca+      28  1.0  0.0 388716  3716 ?        Sl   Jan11 136:27      |           \_ /usr/local/bin/icecast -c /var/azuracast/stations/radio_plato/config/ic
azuraca+      30  0.2  0.0 388716  3160 ?        Sl   Jan11  30:21      |           \_ /usr/local/bin/icecast -c /var/azuracast/stations/radio_plato_-_test_x_
azuraca+      46  7.5 17.3 1748928 701272 ?      SLl  Jan11 987:47      |           \_ /usr/local/bin/liquidsoap /var/azuracast/stations/radio_plato/config/li
azuraca+ 2800539  7.2  8.0 1565660 324600 ?      SLl  06:03  61:09      |           \_ /usr/local/bin/liquidsoap /var/azuracast/stations/radio_plato_-_test_x_
root          19  0.0  0.0   2372    72 ?        Ss   Jan11   0:00      \_ runsv cron
root          21  0.0  0.0   9920   944 ?        S    Jan11   0:02          \_ /usr/sbin/cron -f

The above, with tree sorted by memory usage in human readable form, stat legend or omitted, colors, vsz+rss merged (or replaced with mem+swap), tty removed (no idea how it is useful, but -v, --verbosity flag may turn it back).

The goal is to give a clear understanding which tree is using the most memory. Much like neofetch gives understanding which OS and hardware is used. For that it probably makes sense to sort tree such that last screen contains the branch and processes with most memory usage. It would also help to see the graph of most memory usage over time, with spikes or OOM events, maybe in interactive interface like visidata.

@zenkuro
Copy link

zenkuro commented Feb 4, 2022

top -o %MEM

by https://man7.org/linux/man-pages/man1/top.1.html

ps aux --sort -rss | head
ps aux | sort -nk +4 | tail -n 10

by https://ma.ttias.be/sort-ps-by-memory-usage-in-linux/

@abitrolly
Copy link
Member Author

I want something people can remember and quickly lookup params without internet. top UX from 19xx doesn't fit this requirement.

➜  ~ top -h
  procps-ng 3.3.17
Usage:
  top -hv | -bcEeHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols]

It is also not possible to copy/paste contents while the top is updating itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants