Class: Sensu::Plugins::Prometheus::Checks::Runner
- Inherits:
-
Object
- Object
- Sensu::Plugins::Prometheus::Checks::Runner
- Includes:
- Sensu::Plugins::Prometheus::Checks, Utils::Log
- Defined in:
- lib/sensu/plugins/prometheus/checks/runner.rb
Overview
Execute the configured checks, evaluate the results and set a final output and status.
Constant Summary
Constants included from Sensu::Plugins::Prometheus::Checks
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(config) ⇒ Runner
constructor
Does basic configuration validation and start the object the methods on this class will consume.
-
#run ⇒ Object
Drives the evaluation of regular and custom checks, then calls for the final analysis on collected events.
Methods included from Sensu::Plugins::Prometheus::Checks
#above, #below, #equals, #evaluate
Methods included from Utils::Log
Constructor Details
#initialize(config) ⇒ Runner
Does basic configuration validation and start the object the methods on this class will consume.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sensu/plugins/prometheus/checks/runner.rb', line 22 def initialize(config) raise 'Configuration is empty, abort!' \ if config.nil? || config.empty? raise "Configuration does not specify 'config' section!" \ unless config.key?('config') config['checks'] = [] unless config.key?('checks') config['custom'] = [] unless config.key?('custom') @config = config @events = [] @status = 0 @output = '' @source_nodename_map = nil @prometheus = Sensu::Plugins::Prometheus::Client.new @metrics = Sensu::Plugins::Prometheus::Metrics.new(@prometheus) @tmpl = Sensu::Plugins::Prometheus::Checks::Output.new @dispatcher = Sensu::Plugins::Events::Dispatcher.new end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
18 19 20 |
# File 'lib/sensu/plugins/prometheus/checks/runner.rb', line 18 def events @events end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
18 19 20 |
# File 'lib/sensu/plugins/prometheus/checks/runner.rb', line 18 def output @output end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
18 19 20 |
# File 'lib/sensu/plugins/prometheus/checks/runner.rb', line 18 def status @status end |
Instance Method Details
#run ⇒ Object
Drives the evaluation of regular and custom checks, then calls for the final analysis on collected events.
45 46 47 48 49 |
# File 'lib/sensu/plugins/prometheus/checks/runner.rb', line 45 def run evaluate_checks if @config.key?('checks') evaluate_custom if @config.key?('custom') evaluate_and_dispatch_events end |