Sha256: b2e9fd48fb6abf6fb9c67fb2e85d26cb8fa74d87b72ba3a30a3a340564906796

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

module DashingContrib
  module Nagios
    module Status
      extend self

      def fetch(client, options = {})
        critical = client.service_status(default_critical_options.merge(options))
        warning  = client.service_status(default_warning_options.merge(options))
        ok       = client.service_status(default_ok_options.merge(options))
        unknown  = client.service_status(default_unknown_options.merge(options))
        ok.select! { |check| check['status'] == 'OK' }

        { critical: critical, warning: warning, unknown: unknown, ok: ok }
      end

      private
      def default_critical_options
        { :service_status_types => [:critical], :sort_type => :descending, :sort_option => :last_check }
      end

      def default_warning_options
        { :service_status_types => [:warning], :sort_type => :descending, :sort_option => :last_check }
      end

      def default_unknown_options
        { :service_status_types => [:unknown], :sort_type => :descending, :sort_option => :last_check }
      end

      def default_ok_options
        { :sort_option => :last_check, :sort_type => :descending }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dashing-contrib-0.2.9 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.8 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.7 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.6 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.5 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.4 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.3 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.2 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.1 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.2.0 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.14 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.12 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.11 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.10 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.9 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.8 lib/dashing-contrib/bottles/nagios/status.rb
dashing-contrib-0.1.7 lib/dashing-contrib/bottles/nagios/status.rb