ps_mem icon indicating copy to clipboard operation
ps_mem copied to clipboard

Incorrect number of processes

Open davidhq opened this issue 9 years ago • 10 comments

Hi, I get this:

1.9 GiB +  16.0 MiB =   1.9 GiB ruby (40)

for my ruby processes but when I run ps aux | grep ruby | wc -l, I get 24, not 40... also it looks like this (a lot of defunct processes)

$ ps aux | grep ruby
david     3084  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david     5114  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    10469  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    10484  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    11420  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    13612  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    15320  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    17353  0.0  1.1 242052 47500 pts/18   Sl+   2014  52:41 ruby /home/david/.rbenv/versions/2.1.2/bin/rackup faye.ru -E production
david    17801  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    17859  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    22542  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    22876  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    23697  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    24419  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    24507  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    26512  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    26653  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    27051  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    27057  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    27655  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    28428  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    28987  0.0  1.9 256912 77896 ?        Sl    2014   0:03 ruby update_db.rb
david    29409  0.0  0.0      0     0 ?        Zs    2014   0:00 [ruby] <defunct>
david    30525  0.0  0.0   7836   836 pts/4    S+   15:10   0:00 grep ruby

what gives?

davidhq avatar Jan 01 '15 15:01 davidhq

ps aux gives a truncated command name. Perhaps this gives a better count?

ps -e -o args | grep ruby

pixelb avatar Jan 01 '15 16:01 pixelb

It gives the same number (24)

On Thu, Jan 1, 2015 at 5:33 PM, Pádraig Brady [email protected] wrote:

ps aux gives a truncated command name. Perhaps this gives a better count?

ps -e -o args | grep ruby

— Reply to this email directly or view it on GitHub https://github.com/pixelb/ps_mem/issues/14#issuecomment-68490904.

davidhq avatar Jan 01 '15 17:01 davidhq

Do you get the same number when running as root? sudo ps -e -o args | grep ruby

Also does splitting command line arguments give a better indication of where the ruby processes are comming from? sudo ps_mem -s | grep ruby

pixelb avatar Jan 01 '15 17:01 pixelb

screen shot 2015-01-02 at 11 28 57

davidhq avatar Jan 02 '15 10:01 davidhq

All I can suggest is to add some instrumentation to getCmdName(). Something like:

if cmd == 'ruby':
    print pid, cmd, " ".join(cmdline)

That will show the pids at least and you can see details in /proc/$pid

pixelb avatar Jan 06 '15 10:01 pixelb

Thank you, it's getting clearer now...

Still not sure what is happening but I guess there really are that many processes (I have some fail it looks like but I'll deal with it separatelly)

http://pastebin.com/W6dDY22S

Still not sure still why ps reports less (35 now) ?

Can you see something from that inspection?

thank you

On Tue, Jan 6, 2015 at 11:51 AM, Pádraig Brady [email protected] wrote:

All I can suggest is to add some instrumentation to getCmdName(). Something like:

if cmd == 'ruby': print cmd, " ".join(cmdline)

— Reply to this email directly or view it on GitHub https://github.com/pixelb/ps_mem/issues/14#issuecomment-68851626.

davidhq avatar Jan 06 '15 18:01 davidhq

Hmm do you think the difference is here:

david    28184  0.0  0.4 161780 16844 ?        Sl    2014   8:49 puma

2.9.2 (unix:///var/www/voter/shared/tmp/sockets/puma.sock,tcp://0.0.0.0:3009 )

vs

ruby puma 2.9.2

(unix:///var/www/voter/shared/tmp/sockets/puma.sock,tcp://0.0.0.0:3009)

plus this:

david@theta:/var/www/makersqr$ ps aux | grep spring david 3156 0.0 0.5 160744 21356 ? Sl Jan02 0:00 spring server | 32 | started 90 hours ago david 3216 0.0 0.0 91048 2456 ? Sl 2014 0:00 spring server | 108 | started 1395 hours ago david 3272 0.0 0.6 156632 24744 ? Sl Jan02 0:00 spring server | 38 | started 89 hours ago david 3536 0.0 0.0 162692 2536 ? Sl 2014 0:01 spring server | 125 | started 1203 hours ago david 3655 0.0 0.6 156816 26128 ? Sl 17:00 0:00 spring server | 45 | started 1 hour ago david 3660 0.3 3.7 375956 151624 ? Ssl 17:00 0:21 spring app | 45 | started 1 hour ago | production mode

david 3956 0.3 1.6 256372 68696 ? Ssl 2014 28:19 spring app | 125 | started 152 hours ago | development mode

david 3959 0.3 1.6 256296 67176 ? Ssl 2014 28:30 spring app | 125 | started 152 hours ago | production mode

david 5416 0.0 0.0 155932 2520 ? Sl 2014 0:00 spring server | 55 | started 1749 hours ago david 6489 0.0 0.0 91028 3108 ? Sl 2014 0:00 spring server | 101 | started 1441 hours ago david 6765 0.0 0.0 155844 2596 ? Sl 2014 0:01 spring server | 23 | started 1842 hours ago

so you get more info (the whole command line?) versus just part in ps......

That's it!

On Tue, Jan 6, 2015 at 7:42 PM, David Krmpotic [email protected] wrote:

Thank you, it's getting clearer now...

Still not sure what is happening but I guess there really are that many processes (I have some fail it looks like but I'll deal with it separatelly)

http://pastebin.com/W6dDY22S

Still not sure still why ps reports less (35 now) ?

Can you see something from that inspection?

thank you

On Tue, Jan 6, 2015 at 11:51 AM, Pádraig Brady [email protected] wrote:

All I can suggest is to add some instrumentation to getCmdName(). Something like:

if cmd == 'ruby': print cmd, " ".join(cmdline)

— Reply to this email directly or view it on GitHub https://github.com/pixelb/ps_mem/issues/14#issuecomment-68851626.

davidhq avatar Jan 06 '15 18:01 davidhq

I thought the -s option to ps_mem might have split those out sufficiently. It would be bad if ps_mem was lumping all ruby apps together for example

pixelb avatar Jan 06 '15 19:01 pixelb

Looks like your -s option could be improved because it doesn't operate on the same command line strings as your grouping function... that's why it didn't return ruby spring and ruby puma stuff when I tried it... your debug code did.

davidhq avatar Jan 07 '15 12:01 davidhq

nothing new ?

cybernet avatar Nov 24 '16 10:11 cybernet

@davidhq @cybernet please check if https://github.com/pixelb/ps_mem/pull/75 fixed it :)

allanlaal avatar Oct 19 '22 01:10 allanlaal

@davidhq @cybernet please check if #75 fixed it :)

👍 👍

davidhq avatar Oct 20 '22 14:10 davidhq