You are not logged in.

#1 2013-01-29 17:50:15

Midasx
Member
Registered: 2013-01-18
Posts: 16

[Solved] View process RAM usage in human readable form

I would like to see a list of current proesses and the amount of RAM they are using sorted by the RAM usage. i.e.

100MB's openbox
50MB's firefox
etc...

I can use htop to view RAM % but not MB's (To my knowledge). Is there a program to do this?

Thanks

Last edited by Midasx (2013-01-29 19:03:48)

Offline

#2 2013-01-29 17:55:12

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: [Solved] View process RAM usage in human readable form

This python script is quite useful :
http://www.pixelbeat.org/scripts/ps_mem.py

execute it like this:

$ sudo python scriptname

Last edited by illusionist (2013-01-29 18:05:43)


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#3 2013-01-29 17:59:20

Torxed
Member
Registered: 2013-01-10
Posts: 200

Re: [Solved] View process RAM usage in human readable form

Have you tried changing the memory column to something more useable in htop?

F2 -> Columns -> M_RESIDENT and M_SIZE?
I've got:

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
  518 root       20   0  176M 78340 46984 R 25.4  0.5  7:52.26 /usr/bin/X 
3030  user       20   0  590M  106M 42900 S 25.4  0.7  2:49.20 /usr/lib/chromiu

WHere RES shows M for Mb of ram?
IIRC htop converts bytes to Kb (not KB) automatically if the bytes exceeds 1024, and if that exceeds it converts to Mb and so on.

Last edited by Torxed (2013-01-29 18:02:08)

Offline

#4 2013-01-29 18:11:35

Midasx
Member
Registered: 2013-01-18
Posts: 16

Re: [Solved] View process RAM usage in human readable form

illusionist wrote:

This python script is quite useful :
http://www.pixelbeat.org/scripts/ps_mem.py

execute it like this:

$ sudo python scriptname

I seem to get a syntax error with that script hmm

./ps_mem.py 
  File "./ps_mem.py", line 138
    except getopt.GetoptError, e:
                             ^
SyntaxError: invalid syntax
Torxed wrote:

Have you tried changing the memory column to something more useable in htop?

F2 -> Columns -> M_RESIDENT and M_SIZE?
I've got:

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
  518 root       20   0  176M 78340 46984 R 25.4  0.5  7:52.26 /usr/bin/X 
3030  user       20   0  590M  106M 42900 S 25.4  0.7  2:49.20 /usr/lib/chromiu

WHere RES shows M for Mb of ram?
IIRC htop converts bytes to Kb (not KB) automatically if the bytes exceeds 1024, and if that exceeds it converts to Mb and so on.

I had a tinker with htop settings but nothing gave me a clear display unfortunately. I did get to tweak some settings though smile

Last edited by Midasx (2013-01-29 18:14:34)

Offline

#5 2013-01-29 18:39:59

illusionist
Member
From: localhost
Registered: 2012-04-03
Posts: 498

Re: [Solved] View process RAM usage in human readable form

Here is the version of the script I am using :
http://pastebin.com/8pKtGtyk
Execute it like I posted.


  Never argue with stupid people,They will drag you down to their level and then beat you with experience.--Mark Twain
@github

Offline

#6 2013-01-29 18:58:27

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] View process RAM usage in human readable form

while read command percent rss; do
  if [[ "${command}" != "COMMAND" ]]; then
    rss="$(bc <<< "scale=2;${rss}/1024")";
  fi; 
  printf "%-26s%-8s%s\n" "${command}" "${percent}" "${rss}";
done < <(ps -A --sort -rss -o comm,pmem,rss | sed -n 1,11p)

Example output:

COMMAND                   %MEM    RSS
firefox                   32.4    323.56
urxvtd                    2.4     24.24
mplayer                   1.8     18.50
plugin-containe           1.8     18.23
X                         1.3     13.12
vim                       0.4     4.67
bash                      0.2     2.85
bash                      0.2     2.84
bash                      0.2     2.84
bash                      0.2     2.83

You can tweak it to show all processes, not just the top ten, omit %MEM etc.

Last edited by karol (2013-01-29 19:00:08)

Offline

#7 2013-01-29 19:01:43

Midasx
Member
Registered: 2013-01-18
Posts: 16

Re: [Solved] View process RAM usage in human readable form

illusionist wrote:

Here is the version of the script I am using :
http://pastebin.com/8pKtGtyk
Execute it like I posted.


Ah that works now, thank you smile

Offline

Board footer

Powered by FluxBB