class Diplomat::Check
Methods for interacting with the Consul check API endpoint
Public Instance Methods
Get registered checks @return [OpenStruct] all data associated with the service
# File lib/diplomat/check.rb, line 9 def checks ret = @conn.get '/v1/agent/checks' JSON.parse(ret.body) end
Deregister a check @param check_id [String] the unique id of the check @return [Integer] Status
code
# File lib/diplomat/check.rb, line 52 def deregister(check_id) ret = @conn.get "/v1/agent/check/deregister/#{check_id}" ret.status == 200 end
Warn a check @param check_id [String] the unique id of the check @return [Integer] Status
code
# File lib/diplomat/check.rb, line 76 def fail(check_id) ret = @conn.get "/v1/agent/check/fail/#{check_id}" ret.status == 200 end
Pass a check @param check_id [String] the unique id of the check @return [Integer] Status
code
# File lib/diplomat/check.rb, line 60 def pass(check_id) ret = @conn.get "/v1/agent/check/pass/#{check_id}" ret.status == 200 end
Register a check @param check_id [String] the unique id of the check @param name [String] the name @param notes [String] notes about the check @param script [String] command to be run for check @param interval [String] frequency (with units) of the check execution @param ttl [String] time (with units) to mark a check down @return [Integer] Status
code
# File lib/diplomat/check.rb, line 23 def register_script(check_id, name, notes, script, interval) ret = @conn.put do |req| req.url '/v1/agent/check/register' req.body = JSON.generate( 'ID' => check_id, 'Name' => name, 'Notes' => notes, 'Script' => script, 'Interval' => interval ) end ret.status == 200 end
Register a TTL check @param check_id [String] the unique id of the check @param name [String] the name @param notes [String] notes about the check @param ttl [String] time (with units) to mark a check down @return [Boolean] Success
# File lib/diplomat/check.rb, line 39 def register_ttl(check_id, name, notes, ttl) ret = @conn.put do |req| req.url '/v1/agent/check/register' req.body = JSON.generate( 'ID' => check_id, 'Name' => name, 'Notes' => notes, 'TTL' => ttl ) end ret.status == 200 end
Warn a check @param check_id [String] the unique id of the check @return [Integer] Status
code
# File lib/diplomat/check.rb, line 68 def warn(check_id) ret = @conn.get "/v1/agent/check/warn/#{check_id}" ret.status == 200 end