Including child processes in CPU/memory usage #30

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants
@jstepien

This changeset allows God to watch total CPU/memory usage of a process family. I use God to monitor a deamon which forks a lot and monitoring a single PID isn't sufficient. Now I can simply add a following restart rule in order to keep the whole family under control.

w.restart_if do |restart|
  restart.condition(:memory_usage) do |c| 
    c.above = 210.megabytes
    c.times = 5 
    c.family = true
  end 

  restart.condition(:cpu_usage) do |c| 
    c.above = 80.percent
    c.times = 5 
    c.family = true
  end 
end 

rake test doesn't report any regressions.

@mojombo

This comment has been minimized.

Show comment
Hide comment
@mojombo

mojombo May 25, 2011

Owner

This looks really useful. Any chance you could work up a test for this, to make sure it's working properly?

Owner

mojombo commented May 25, 2011

This looks really useful. Any chance you could work up a test for this, to make sure it's working properly?

@jstepien

This comment has been minimized.

Show comment
Hide comment
@jstepien

jstepien May 25, 2011

Sure. Here's a memory usage test. I guess something similar can be written to test CPU usage. Looking forward for your opinion.

Sure. Here's a memory usage test. I guess something similar can be written to test CPU usage. Looking forward for your opinion.

@mojombo

This comment has been minimized.

Show comment
Hide comment
@mojombo

mojombo May 25, 2011

Owner

I'm getting the following error on my system (OSX):

  1) Error:
test_family_memory_usage(TestSystemProcessFamily):
TypeError: #<Mocha::Mock:0x1033f6bd8> is not a class/module
    ./test/test_system_process_family.rb:36:in `test_family_memory_usage'
    /Users/tom/.rvm/gems/ruby-1.8.7-p248/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `__send__'
    /Users/tom/.rvm/gems/ruby-1.8.7-p248/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `run'

Are you seeing this at all?

Owner

mojombo commented May 25, 2011

I'm getting the following error on my system (OSX):

  1) Error:
test_family_memory_usage(TestSystemProcessFamily):
TypeError: #<Mocha::Mock:0x1033f6bd8> is not a class/module
    ./test/test_system_process_family.rb:36:in `test_family_memory_usage'
    /Users/tom/.rvm/gems/ruby-1.8.7-p248/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `__send__'
    /Users/tom/.rvm/gems/ruby-1.8.7-p248/gems/mocha-0.9.12/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:22:in `run'

Are you seeing this at all?

@jstepien

This comment has been minimized.

Show comment
Hide comment
@jstepien

jstepien May 26, 2011

No, I'm not, but I also had some problems. I'm on Linux and Ruby 1.9.2. I copied the test file structure from test/test_system_process.rb. I wasn't able to run test/test_system_process.rb and the test I've added using Rake. I've managed to run them using

$ ruby -I path/to/mocha-0.9.12/lib/ -I. test/test_system_process.rb
$ ruby -I path/to/mocha-0.9.12/lib/ -I. test/test_system_process_family.rb

Without adding mocha to the load path I get a following error.

$ ruby -I. test/test_system_process.rb 
E [2011-05-26 16:44:09] ERROR: => You need the Mocha gem to run these tests.

No, I'm not, but I also had some problems. I'm on Linux and Ruby 1.9.2. I copied the test file structure from test/test_system_process.rb. I wasn't able to run test/test_system_process.rb and the test I've added using Rake. I've managed to run them using

$ ruby -I path/to/mocha-0.9.12/lib/ -I. test/test_system_process.rb
$ ruby -I path/to/mocha-0.9.12/lib/ -I. test/test_system_process_family.rb

Without adding mocha to the load path I get a following error.

$ ruby -I. test/test_system_process.rb 
E [2011-05-26 16:44:09] ERROR: => You need the Mocha gem to run these tests.
+ # Returns an array of PIDs of the polled process and all its children.
+ def family

This comment has been minimized.

@eric

eric Dec 17, 2011

Collaborator

This method should be moved into the PortablePoller and an implementation should be written for the SlashProcPoller.

@eric

eric Dec 17, 2011

Collaborator

This method should be moved into the PortablePoller and an implementation should be written for the SlashProcPoller.

@quentindemetz

This comment has been minimized.

Show comment
Hide comment
@quentindemetz

quentindemetz May 19, 2016

I would like to see this merged - @mojombo what should I do to move this forward ?
Thanks

I would like to see this merged - @mojombo what should I do to move this forward ?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment