lib/sensu/client/process.rb
# Run a check extension and publish the result. The Sensu client
# loads check extensions, checks that run within the Sensu Ruby
# VM and the EventMachine event loop, using the Sensu Extension
# API. If a check definition includes `:extension`, use it's
# value for the extension name, otherwise use the check name.
# The check definition is passed to the extension `safe_run()`
# method as a parameter, the extension may utilize it. This
# method guards against multiple executions for the same check
# extension.
#
# https://github.com/sensu/sensu-extension
#
# @param check [Hash]
Run a check extension and publish the result. The Sensu client
loads check extensions, checks that run within the Sensu Ruby
VM and the EventMachine event loop, using the Sensu Extension
API. If a check definition includes `:extension`, use it's
value for the extension name, otherwise use the check name.
The check definition is passed to the extension `safe_run()`
method as a parameter, the extension may utilize it. This
method guards against multiple executions for the same check
extension.


Run a check extension and publish the result . The Sensu client loads check extensions checks that run within the Sensu Ruby VM and the EventMachine event loop using the Sensu Extension API . If a check definition includes ` : extension ` use it ' s value for the extension name otherwise use the check name . The check definition is passed to the extension ` safe_run () ` method as a parameter the extension may utilize it . This method guards against multiple executions for the same check extension .
def run_check_extension(check)
        @logger.debug("attempting to run check extension", :check => check)
        in_progress_key = check_in_progress_key(check)
        unless @checks_in_progress.include?(in_progress_key)
          @checks_in_progress << in_progress_key
          started = Time.now.to_f
          check[:executed] = started.to_i
          extension_name = check[:extension] || check[:name]
          extension = @extensions[:checks][extension_name]
          extension.safe_run(check) do |output, status|
            check[:duration] = ("%.3f" % (Time.now.to_f - started)).to_f
            check[:output] = output
            check[:status] = status
            if check[:hooks] && !check[:hooks].empty?
              execute_check_hook(check) do |check|
                publish_check_result(check)
                @checks_in_progress.delete(in_progress_key)
              end
            else
              publish_check_result(check)
              @checks_in_progress.delete(in_progress_key)
            end
          end
        else
          @logger.warn("previous check extension execution in progress", :check => check)
        end
      end
def run_check_extension ( check ) @logger . debug ( "attempting to run check extension" , :check => check ) in_progress_key = check_in_progress_key ( check ) unless @checks_in_progress . include? ( in_progress_key ) @checks_in_progress << in_progress_key started = Time . now . to_f check [ :executed ] = started . to_i extension_name = check [ :extension ] || check [ :name ] extension = @extensions [ :checks ] [ extension_name ] extension . safe_run ( check ) do | output , status | check [ :duration ] = ( "%.3f" % ( Time . now . to_f - started ) ) . to_f check [ :output ] = output check [ :status ] = status if check [ :hooks ] && ! check [ :hooks ] . empty? execute_check_hook ( check ) do | check | publish_check_result ( check ) @checks_in_progress . delete ( in_progress_key ) end else publish_check_result ( check ) @checks_in_progress . delete ( in_progress_key ) end end else @logger . warn ( "previous check extension execution in progress" , :check => check ) end end
Run a check extension and publish the result.
Run a check extension and publish the result .
check
None