Sha256: 75324625dd4045e3232b017b198f3db955206cb146768134c395c11410544a04

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

class Riemann::Babbler::Runit < Riemann::Babbler

  def init
    plugin.set_default(:service, 'runit')
    plugin.set_default(:not_monit, [])
    plugin.set_default(:interval, 10)
  end

  def run_plugin
    Dir.exists? '/etc/service'
    @status_history = Array.new
  end

  def read_run_status
    status = Array.new
    Dir.glob('/etc/service/*').each do |srv|
      next if plugin.not_monit.include? srv
      human_srv = ' ' + srv.gsub(/\/etc\/service\//,"")
      stat_file = File.join(srv, 'supervise', 'stat')
      next unless File.exists? stat_file
      if File.read( stat_file ).strip == 'run'
        @status_history.delete "human_srv"
        status << {:service => plugin.service + human_srv , :state => 'ok', :description => "runit service #{human_srv} running"}
      else
        status << {:service => plugin.service + human_srv , :state => 'critical', :description => "runit service #{human_srv} not running"} if @status_history.include? human_srv 
        @status_history << human_srv unless @status_history.include? human_srv
      end
    end
    status
  end

  def collect
    read_run_status
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
riemann-babbler-0.9.9.7 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9.6 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9.5 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9.4 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9.3 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9.2 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9.1 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-0.9.9 lib/riemann/babbler/plugins/runit.rb