Sha256: 5ed5f3ec90ed8544ccbe43e2814c4e6d026197f363dcf6166728b939cff260b5
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
module Riemann module Babbler require 'riemann/client' def self.included(base) base.instance_eval do def run new.run end end end def initialize @configatron = $configatron super end def log @logger ||= $logger end def options @configatron end alias :opts :options def report(event) event[:tags] unless options.riemann.tags.nil? riemann << event end def riemann @riemann ||= Riemann::Client.new( :host => options.riemann.host, :port => options.riemann.port ) end alias :r :riemann def run t0 = Time.now loop do begin tick rescue => e $stderr.puts "#{e.class} #{e}\n#{e.backtrace.join "\n"}" end # Sleep. sleep(plugin.interval - ((Time.now - t0) % plugin.interval)) end end # Переодически вызываемое действие def tick end # Доступ к конфигу определенного плагина def plugin end # описание статуса def state(my_state) case when my_state.between?(plugin.states.warning, plugin.states.critical) 'warning' when my_state > plugin.states.warning 'critical' else 'ok' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-0.0.2 | lib/riemann/babbler/plugin.rb |
riemann-babbler-0.0.1 | lib/riemann/babbler/plugin.rb |