kostya / eye

Process monitoring tool. Inspired from Bluepill and God.
MIT License
1.19k stars 89 forks source link

running custom code in check :memory #216

Closed jbmyid closed 6 years ago

jbmyid commented 6 years ago

Is there any way to run some code when the memory/cpu of process reaches some value.

I have an scenario for debugging purpose where I have to run some code when memory of the process reaches to certain value.

kostya commented 6 years ago
def on_my_check(process)
  process.info "test"
  process.execute_async "sendxmpp -s 'hhahahaa' someone@jabber.org"
  File.open("/tmp/triggered.txt", "w") { |f| f.write 1 }
end

Eye.app :bla do
  process :a do
    # ...
    check :memory, every: 20.seconds, below: 300.megabytes, times: 3, 
           fires: [-> { on_my_check(self) }, :restart]
  end
end
jbmyid commented 6 years ago

Thanks I will try this.