ps_mem icon indicating copy to clipboard operation
ps_mem copied to clipboard

Add no-humanize and remove root verification

Open pik opened this issue 8 years ago • 2 comments

This PR adds a --no-humanize flag to allow writing the ps_mem output in an easily machine parsable form (e.g. useful for later graphing the data in matplotlib).

Also I believe the root user verification is an artifact of some older code? As long as the process running is owned by the user ps_mem run by the user will have access to the appropriate proc files.

On a side-note I'm quite curious as to the point of the if pss branch in print_memory_usage -- here is the difference in output with the code present and with the code commented out:

 28.2 MiB +   2.5 MiB =  30.6 MiB   nm-applet
---------------------------------
                         30.6 MiB
=================================
 28.2 MiB +   2.5 MiB =  30.6 MiB   nm-applet
---------------------------------
                         30.6 MiB

vs.

 28.2 MiB +   2.5 MiB =  30.6 MiB   nm-applet
 28.2 MiB +   2.5 MiB =  30.6 MiB   nm-applet
 28.2 MiB +   2.5 MiB =  30.6 MiB   nm-applet

It's really hard for me to tell what the delimiter lines are adding here.. Perhaps the entire branch should be pruned?

pik avatar Jul 20 '16 20:07 pik

Re getting totals for further processing, does the filtering + --total option handle your use case? I.E. would this work for you? ps_mem -t -p $(pidof nm-applet)

pixelb avatar Jul 21 '16 08:07 pixelb

@pixelb Well this way you can get the share-mem / swap use included as well e.g.

> python ps_mem.py -p 14256 --swap --no-humanize
968.0,4593.5,5561.5,362,476,chromium

(also the number of processes if they are multiples)

> sudo python ps_mem.py -p (pgrep chromium | paste -sd ',' -) --swap --no-humanize -w 1
1078916.0,94137.5,1173053.5,7006,18232,chromium (13)
1078916.0,94137.5,1173053.5,7006,18232,chromium (13)

pik avatar Jul 21 '16 14:07 pik