pixelb / ps_mem

A utility to accurately report the in core memory usage for a program
GNU Lesser General Public License v2.1
1.54k stars 282 forks source link

ADD option to only include `RAM used` column (omits Private and Shared) #76

Open allanlaal opened 1 year ago

allanlaal commented 1 year ago

Add a separate command line flag, so the output columns would only be RAM used and Program (and whatever new ones are added)

use case:

I only care about total RAM used per app

pixelb commented 1 year ago

You could take advantage of the alignment to do ps_mem | cut -b25-. I suppose we could add an option to select columns (which would generalize -S that shows the swap column). Re alignment we wouldn't be able to rely on alignment if we let users choose a unit (which is probably a good idea (as per issue #39))

allanlaal commented 1 year ago

@pixelb custom columns would still result in a known and repeatable alignment for those columns, no?

pixelb commented 1 year ago

Right. Alignment issues would only be for configurable units. Columns would not impact that

zen2 commented 2 months ago

The best way to support custom display is to propose several options as classical linux commands:

-h -> for human display (scale value to shortest three digit unit and display unit - actual ps_mem default) --units=UNITS -> to force unit usage (without print unit) -o (--output) -> option that takes a comma-separated list of output fields as private, shared, used, process --no-headers or --headers -> display columns header line or not --separator=SEPARATOR -> to choose separator

Actually ps_mem used -h and --headers by default. -o/--no-headers/--separator permit to create csv output that can be easily parsed by other commands or programs.

Alignment is not an issue if columns size are calculated dynamically as the unix command "column -t" does.

Note: I actually parsed ps_mem output by my own monitoring nrpe script to graph main process usage on servers. Adding these options could bring ps_mem to a classical unix command for years !