Class: Diplomat::Check
- Inherits:
-
RestClient
- Object
- RestClient
- Diplomat::Check
- Defined in:
- lib/diplomat/check.rb
Class Method Summary collapse
- .checks ⇒ Object
- .deregister(*args) ⇒ Object
- .fail(*args) ⇒ Object
- .pass(*args) ⇒ Object
- .register_script(*args) ⇒ Object
- .register_ttl(*args) ⇒ Object
- .warn(*args) ⇒ Object
Instance Method Summary collapse
-
#checks ⇒ OpenStruct
Get registered checks.
-
#deregister(check_id) ⇒ Integer
Deregister a check.
-
#fail(check_id) ⇒ Integer
Warn a check.
-
#pass(check_id) ⇒ Integer
Pass a check.
-
#register_script(check_id, name, notes, script, interval) ⇒ Integer
Register a check.
- #register_ttl(check_id, name, notes, ttl) ⇒ Object
-
#warn(check_id) ⇒ Integer
Warn a check.
Methods inherited from RestClient
Constructor Details
This class inherits a constructor from Diplomat::RestClient
Class Method Details
.checks ⇒ Object
Note:
This is sugar, see (#checks)
92 93 94 |
# File 'lib/diplomat/check.rb', line 92 def self.checks Diplomat::Check.new.checks end |
.deregister(*args) ⇒ Object
Note:
This is sugar, see (#deregister)
107 108 109 |
# File 'lib/diplomat/check.rb', line 107 def self.deregister *args Diplomat::Check.new.deregister *args end |
.fail(*args) ⇒ Object
Note:
This is sugar, see (#fail)
122 123 124 |
# File 'lib/diplomat/check.rb', line 122 def self.fail *args Diplomat::Check.new.fail *args end |
.pass(*args) ⇒ Object
Note:
This is sugar, see (#pass)
112 113 114 |
# File 'lib/diplomat/check.rb', line 112 def self.pass *args Diplomat::Check.new.pass *args end |
.register_script(*args) ⇒ Object
Note:
This is sugar, see (#register_script)
97 98 99 |
# File 'lib/diplomat/check.rb', line 97 def self.register_script *args Diplomat::Check.new.register_script *args end |
.register_ttl(*args) ⇒ Object
Note:
This is sugar, see (#register_ttl)
102 103 104 |
# File 'lib/diplomat/check.rb', line 102 def self.register_ttl *args Diplomat::Check.new.register_ttl *args end |
.warn(*args) ⇒ Object
Note:
This is sugar, see (#warn)
117 118 119 |
# File 'lib/diplomat/check.rb', line 117 def self.warn *args Diplomat::Check.new.warn *args end |
Instance Method Details
#checks ⇒ OpenStruct
Get registered checks
9 10 11 12 |
# File 'lib/diplomat/check.rb', line 9 def checks ret = @conn.get "/v1/agent/checks" return JSON.parse(ret.body) end |
#deregister(check_id) ⇒ Integer
Deregister a check
62 63 64 65 |
# File 'lib/diplomat/check.rb', line 62 def deregister check_id ret = @conn.get "/v1/agent/check/deregister/#{check_id}" return true if ret.status == 200 end |
#fail(check_id) ⇒ Integer
Warn a check
86 87 88 89 |
# File 'lib/diplomat/check.rb', line 86 def fail check_id ret = @conn.get "/v1/agent/check/fail/#{check_id}" return true if ret.status == 200 end |
#pass(check_id) ⇒ Integer
Pass a check
70 71 72 73 |
# File 'lib/diplomat/check.rb', line 70 def pass check_id ret = @conn.get "/v1/agent/check/pass/#{check_id}" return true if ret.status == 200 end |
#register_script(check_id, name, notes, script, interval) ⇒ Integer
Register a check
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/diplomat/check.rb', line 22 def register_script check_id, name, notes, script, interval json = JSON.generate( { "ID" => check_id, "Name" => name, "Notes" => notes, "Script" => script, "Interval" => interval } ) ret = @conn.put do |req| req.url "/v1/agent/check/register" req.body = json end return true if ret.status == 200 end |
#register_ttl(check_id, name, notes, ttl) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/diplomat/check.rb', line 41 def register_ttl check_id, name, notes, ttl json = JSON.generate( { "ID" => check_id, "Name" => name, "Notes" => notes, "TTL" => ttl, } ) ret = @conn.put do |req| req.url "/v1/agent/check/register" req.body = json end return true if ret.status == 200 end |
#warn(check_id) ⇒ Integer
Warn a check
78 79 80 81 |
# File 'lib/diplomat/check.rb', line 78 def warn check_id ret = @conn.get "/v1/agent/check/warn/#{check_id}" return true if ret.status == 200 end |