Sha256: 851bc22f1d3797ce44fb1b9f1313f343f4b7962bcf16d0a382b23376fcc13758
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
# encoding: utf-8 require "kurchatov/plugin" require "kurchatov/mashie" require "kurchatov/mixin/init" module Kurchatov module Plugins class Riemann < Kurchatov::Plugin include Kurchatov::Mixin::Queue include Kurchatov::Mixin::Ohai include Kurchatov::Mixin::Event include Kurchatov::Mixin::Command include Kurchatov::Mixin::Http attr_accessor :run_if, :collect, :always_start, :interval, :plugin def initialize(name = '') super(name) @run_if = Proc.new {true} @plugin = Mashie.new @always_start = false @collect = nil @interval = 60 end def run loop do t_start = Time.now Timeout::timeout(interval * 2/3) do self.instance_eval(&collect) end sleep(interval - (Time.now - t_start).to_i) end end def respond_to_ohai?(opts = {}) opts.each { |k,v| return false unless ohai[k] == v } true end def runnable_by_config? Log.info("Plugin '#{self.name}' disabled by nil collect") and return if collect.nil? Log.info("Plugin '#{self.name}' disabled in config") and return if plugin[:disable] == true Log.info("Plugin '#{self.name}' not started by run_if condition ") and return if !self.instance_eval(&run_if) @plugin[:service] = name if @plugin[:service].nil? true end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kurchatov-0.0.2 | lib/kurchatov/plugin/riemann.rb |
kurchatov-0.0.2b | lib/kurchatov/plugin/riemann.rb |
kurchatov-0.0.1 | lib/kurchatov/plugin/riemann.rb |