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

Add no-humanize and remove root verification #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pik
Copy link

@pik pik commented Jul 20, 2016

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?

@pixelb
Copy link
Owner

pixelb commented Jul 21, 2016

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)

@pik
Copy link
Author

pik commented Jul 21, 2016

@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)

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

Successfully merging this pull request may close these issues.

2 participants