class Sensu::Push::Check

Attributes

name[R]
namespace[R]
output[R]
status[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/sensu/push/check.rb, line 8
def initialize(options={})
  @options = options
  @name = @options[:check_name]
  @namespace = @options.fetch(:namespace, "default")
end

Public Instance Methods

exec!() click to toggle source
# File lib/sensu/push/check.rb, line 14
def exec!
  stdin, stdout, stderr, wait = Open3.popen3(@options[:command])
  @output = "#{stdout.read}\n#{stderr.read}"
  @status = wait.value.exitstatus
  [@output, @status]
end
to_hash() click to toggle source
# File lib/sensu/push/check.rb, line 21
def to_hash
  {
    :metadata => {
      :name => @name,
      :namespace => @namespace
    },
    :command => @options[:command],
    :output => @output,
    :status => @status,
    :ttl => @options.fetch(:ttl, 0)
  }
end