Class: Alerty

Inherits:
Object
  • Object
show all
Defined in:
lib/alerty.rb,
lib/alerty/cli.rb,
lib/alerty/error.rb,
lib/alerty/config.rb,
lib/alerty/logger.rb,
lib/alerty/command.rb,
lib/alerty/version.rb,
lib/alerty/plugin/exec.rb,
lib/alerty/plugin/file.rb,
lib/alerty/string_util.rb,
lib/alerty/plugin/stdout.rb,
lib/alerty/plugin_factory.rb

Defined Under Namespace

Classes: CLI, Command, Config, ConfigError, Error, Logger, Plugin, PluginFactory, StringUtil

Constant Summary collapse

VERSION =
'0.4.0'

Class Method Summary collapse

Class Method Details

.loggerObject



11
12
13
14
15
# File 'lib/alerty.rb', line 11

def self.logger
  @logger ||= Logger.new(Config.log_path, Config.log_shift_age, Config.log_shift_size).tap do |logger|
    logger.level = Config.log_level
  end
end

.send(record) ⇒ Object

Parameters:

  • record (Hash)

Options Hash (record):

  • :hostname (String)
  • :command (String)
  • :exitstatus (Integer)
  • :output (String)
  • :started_at (Float)

    unix timestamp

  • :duration (Float)
  • :retries (Integer)

    number of being retried



25
26
27
28
29
30
31
32
33
34
# File 'lib/alerty.rb', line 25

def self.send(record)
  PluginFactory.plugins.each do |plugin|
    begin
      plugin.alert(record)
    rescue => e
      puts "#{e.class} #{e.message} #{e.backtrace.join("\n")}" if Config.debug?
      Alerty.logger.warn "#{e.class} #{e.message} #{e.backtrace.join("\n")}"
    end
  end
end