Sha256: a2fc7bb18cf2ad266867488924081a5ad655c12e27c8ae7ba3968f3299ee4206

Contents?: true

Size: 966 Bytes

Versions: 40

Compression:

Stored size: 966 Bytes

Contents

class Riemann::Babbler::Plugin::ErrorsReporter < Riemann::Babbler::Plugin

  def init
    plugin.set_default(:service, 'riemann client')
    @report_ok = false
  end

  def collect
    status   = Array.new
    messages = Array.new

    opts.errors.to_hash.each do |plugin_name, plugin_status|
      next if plugin_status[:reported]
      messages << "#{plugin_name} count_errors: #{plugin_status[:count]}, \
        last: #{plugin_status[:last_error_at]}"
      opts.errors.send(plugin_name).reported = true
    end

    if messages.empty?
      status << { :service => plugin.service, :state => 'ok', :description => "All plugins ok" } unless @report_ok
      @report_ok = true
    else
      @report_ok = false
      status << {
          :service     => plugin.service,
          :state       => 'critical',
          :metric      => messages.count,
          :description => "Problem with plugins:\n #{messages.join("\n")}"
      }
    end
    status
  end

end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
riemann-babbler-2.1.3.1 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.1.3 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.1.2 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.1.1 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.1.0 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.9 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.8 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.7 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.6.1 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.6 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.5 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.4 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.3.2 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.3.1 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.3 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.2 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.1 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.0 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.0pre15 lib/riemann/babbler/plugins/errors_reporter.rb
riemann-babbler-2.0.0pre13 lib/riemann/babbler/plugins/errors_reporter.rb