Skip to content

ps alternative to "who eats memory" #51

@abitrolly

Description

@abitrolly

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions