Class: Sensu::API::Validators::Check

Inherits:
Object
  • Object
show all
Includes:
Settings::Rules, Settings::Validators::Check
Defined in:
lib/sensu/api/validators/check.rb

Instance Method Summary collapse

Instance Method Details

#valid?(check) ⇒ TrueClass, FalseClass

Determine if a check definition is valid.

Parameters:

  • check (Hash)

Returns:

  • (TrueClass, FalseClass)


37
38
39
40
41
42
# File 'lib/sensu/api/validators/check.rb', line 37

def valid?(check)
  validate_check_result(check)
  true
rescue Invalid
  false
end

#validate_check_result(check) ⇒ Object

Validate a check result, selectively using check definition validation methods.

Parameters:

  • check (Hash)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sensu/api/validators/check.rb', line 17

def validate_check_result(check)
  must_be_a_string(check[:output]) ||
    invalid(check, "check output must be a string")
  must_be_an_integer(check[:status]) ||
    invalid(check, "check status must be an integer")
  must_be_an_integer(check[:executed]) ||
    invalid(check, "check executed timestamp must be an integer")
  validate_check_name(check)
  validate_check_handling(check)
  validate_check_aggregate(check)
  validate_check_flap_detection(check)
  validate_check_truncate_output(check)
  validate_check_source(check) if check[:source]
  validate_check_ttl(check) if check[:ttl]
end