Sha256: 6f4aeaf0986b82a43a6897bf7340a89275a8f52c660a630d0f6be74a9990e6c3

Contents?: true

Size: 1.12 KB

Versions: 12

Compression:

Stored size: 1.12 KB

Contents

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

  def init
    plugin.set_default(:service, 'runit')
    plugin.set_default(:not_monit, [])
    plugin.set_default(:interval, 60)
  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
        if @status_history.include? human_srv 
          status << {:service => plugin.service + human_srv , :state => 'critical', :description => "runit service #{human_srv} not running"}
        end
        @status_history << human_srv unless @status_history.include? human_srv
      end
    end
    status
  end

  def collect
    read_run_status
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
riemann-babbler-1.2.0 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.1.9 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.1.7 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.1.6 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.8 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.7 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.6 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.5 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.4 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.3 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.2 lib/riemann/babbler/plugins/runit.rb
riemann-babbler-1.0.8.1 lib/riemann/babbler/plugins/runit.rb