Sha256: 12e411c897f615778eef79a798ef4db46a1e5840c30d5fc06def305725087eeb

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

#!/usr/bin/env ruby
#encoding: utf-8

require 'trollop'
require 'yaml'
require 'configatron'
require 'logger'

require File.expand_path('../../lib/riemann/version', __FILE__)
require File.expand_path('../../lib/deep_merge', __FILE__)
require File.expand_path('../../lib/riemann/babbler/plugin', __FILE__)

opts = Trollop::options do
  version "Riemann babbler #{Riemann::Babbler::VERSION}"
  banner <<-EOS
Riemann-babbler is plugin manager for riemann-tools.

Usage:
       riemann-babbler [options] 
where [options] are:
EOS

  opt :config, "Config file", :default => "/etc/riemann-babbler/config.yml"
end

# logger
logger = Logger.new(STDOUT)

# merge configs
config_file =  if File.exist?( opts[:config] )
  YAML.load_file( opts[:config] ).to_hash
else
  log.error "Can't load config file #{opts[:config]}"
  Hash.new
end

config_default = YAML.load_file( File.expand_path('../../config.yml', __FILE__) )

config = config_default.deep_merge( config_file )
configatron.configure_from_hash config

# get plugins
plugins = []
default_plugins_dir = File.expand_path('../../lib/riemann/babbler/plugins/', __FILE__)
Dir.glob( default_plugins_dir + "/*.rb" ) do |file|
  plugins <<  file
end

unless configatron.plugins.dirs.nil?
  configatron.plugins.dirs.each do |dir|
    next unless Dir.exist? dir
    Dir.glob( dir + "/*.rb" ) do |file|
      plugins << file
    end
  end
end

unless configatron.plugins.files.nil?
  configatron.plugins.files.each do |file|
    plugins << file
  end
end

# start plugins
plugins.each { |plugin| require plugin }

plugin_threads = Riemann::Babbler.registered_plugins.map do |plugin|
  Thread.new {
    plugin.new( configatron, logger ).run
  }
end

Signal.trap "USR1" do
  plugin_threads.each( &:kill )
end

plugin_threads.each( &:join )

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
riemann-babbler-0.4.0 bin/riemann-babbler
riemann-babbler-0.3.7 bin/riemann-babbler
riemann-babbler-0.3.6 bin/riemann-babbler
riemann-babbler-0.3.5 bin/riemann-babbler
riemann-babbler-0.3.4 bin/riemann-babbler
riemann-babbler-0.3.3 bin/riemann-babbler