kostya / eye

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

Unable to make notification work #219

Closed umsh1ume closed 6 years ago

umsh1ume commented 6 years ago

Sorry to put a question here. I was using eye to monitor my sidekiq, but I am not receiving notification mails. I know that most probably, my config syntax itself is wrong but I am not able to find a complete documentation or tutorial anywhere. Eye is monitoring fine and it restart sidekiq when I kill sidekiq process but its not sending email notification

Eye.config do
  logger "/tmp/eye.log"
  mail domain: 'smtp@gmail.com', host: 'smtp@gmail.com', port: 587, from_mail: "umeshmalhotra1995@gmail.com", password: "xxxxxx", from_name: "Umesh"
  contact :dev, :mail, "umeshmalhotra1995@gmail.com"
end

def sidekiq_process(proxy, name)
  rails_env = proxy.env['RAILS_ENV']

  proxy.process(name) do
    start_command "bundle exec sidekiq -e development"
    pid_file "/home/dms_master/dms_webapp/tmp/pids/sidekiq_development.pid"
    stdall "/home/dms_master/dms_webapp/log/sidekiqdevelopment.log"
    daemonize true
    stop_signals [:USR1, 0, :TERM, 10.seconds, :KILL]

    check :cpu, every: 30, below: 100, times: 5
    check :memory, every: 30, below: 300.megabytes, times: 5
  end
end

Eye.application :sidekiq_test do
  notify :errors
  notify :dev
  # All options inherits down to the config leafs.
  # except `env`, which merging down

  # uid "user_name" # run app as a user_name (optional) - available only on ruby >= 2.0
  # gid "group_name" # run app as a group_name (optional) - available only on ruby >= 2.0

  working_dir "/home/dms_master/dms_webapp"
  stdall 'trash.log' # stdout,err logs for processes by default
  env 'APP_ENV' => 'development' # global env for each processes
  trigger :flapping, times: 10, within: 1.minute, retry_in: 10.minutes
  #check :cpu, every: 10.seconds, below: 100, times: 3 # global check for all processes

  working_dir File.expand_path(File.join(File.dirname(__FILE__), %w[ ../ ]))
  env 'RAILS_ENV' => 'production'

  sidekiq_process(self, :sidekiq)
end

Please help me in correcting my mistake

kostya commented 6 years ago

example of notify: https://github.com/kostya/eye/blob/master/examples/notify.eye

try to change memory check to check :memory, every: 30, below: 1.megabytes, times: 5, this 100% trigger restart and should send notify (also this would be in log).

Also i guess you set password, but not set user option (from_mail option not used for auth): options https://github.com/kostya/eye/blob/master/lib/eye/notify/mail.rb#L14

Also you can just try to manually execute code from https://github.com/kostya/eye/blob/master/lib/eye/notify/mail.rb, to check your email connection

umsh1ume commented 6 years ago

Hi, thanks for replying. After reducing memory check to 1.megabytes, it does indeed trigger restart, but still no notification mails are being sent. I changed my config as you suggested

mail :host => "smtp.gmail.com", :port => 587, :user => "umeshmalhotra1995@gmail.com", :password => "xxxxx", :domain => "smtp.gmail.com"
  contact :errors, :mail, "umeshmalhotra1995@gmail.com"
  contact :dev, :mail, 'umeshmalhotra1995@gmail.com'

But I am getting this error

 ERROR -- [celluloid] Actor crashed!
Net::SMTPAuthenticationError: 530 5.7.0 Must issue a STARTTLS command first. y85-v6sm47255353pfa.170 - gsmtp

Thanks in advance

umsh1ume commented 6 years ago

Hi, I manually executed the code from https://github.com/kostya/eye/blob/master/lib/eye/notify/mail.rb , I ended up using :auth => :plain, :starttls => true in my mail config and it worked. Thanks