Sha256: 7225b4c31178700d343e6019857443f21884768f5ac0ce4804fadf7e5b99d4a2

Contents?: true

Size: 822 Bytes

Versions: 18

Compression:

Stored size: 822 Bytes

Contents

module Eye::Process::Notify

  # notify to user:
  # 1) process crashed by itself, and we restart it [:info]
  # 2) checker bounded to restart process [:warn]
  # 3) flapping + switch to unmonitored [:error]

  LEVELS = {:debug => 0, :info => 1, :warn => 2, :error => 3, :fatal => 4}

  def notify(level, msg)
    # logging it
    error "NOTIFY: #{msg}" if ilevel(level) > ilevel(:info)

    # send notifies
    if self[:notify].present?
      message = {:message => msg, :name => name,
        :full_name => full_name, :pid => pid, :host => Eye::Local.host, :level => level,
        :at => Time.now }

      self[:notify].each do |contact, not_level|
        Eye::Notify.notify(contact, message) if ilevel(level) >= ilevel(not_level)
      end
    end
  end

private

  def ilevel(level)
    LEVELS[level].to_i
  end

end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
eye-0.8.pre2 lib/eye/process/notify.rb
eye-0.8.pre lib/eye/process/notify.rb
eye-0.7 lib/eye/process/notify.rb
eye-0.7.pre lib/eye/process/notify.rb
eye-0.6.4 lib/eye/process/notify.rb
eye-0.6.3 lib/eye/process/notify.rb
eye-0.6.2 lib/eye/process/notify.rb
eye-0.6.2.pre lib/eye/process/notify.rb
eye-0.6.1 lib/eye/process/notify.rb
ace-eye-0.6.3 lib/eye/process/notify.rb
ace-eye-0.6.2 lib/eye/process/notify.rb
ace-eye-0.6.1 lib/eye/process/notify.rb
eye-0.6 lib/eye/process/notify.rb
reel-eye-0.5.2.1 lib/eye/process/notify.rb
reel-eye-0.5.2 lib/eye/process/notify.rb
eye-0.5.2 lib/eye/process/notify.rb
reel-eye-0.5.1 lib/eye/process/notify.rb
eye-0.5.1 lib/eye/process/notify.rb