Module: Handler
- Defined in:
- lib/chaoite/handler.rb
Class Method Summary collapse
- .http_metric(config) ⇒ Object
- .http_state(config) ⇒ Object
- .shell_metric(config) ⇒ Object
- .shell_state(config) ⇒ Object
Class Method Details
.http_metric(config) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/chaoite/handler.rb', line 20 def http_metric config begin res = Net::HTTP.get_response(URI(config["check"])) parse(res.body, config) rescue Exception => e puts e nil end end |
.http_state(config) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/chaoite/handler.rb', line 9 def http_state config key = config["key"] value = begin res = Net::HTTP.get_response(URI(config["check"])) res.code == '200' ? 1 : 0 rescue 0 end return key => value end |
.shell_metric(config) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chaoite/handler.rb', line 37 def shell_metric config key = config["key"] command = config["check"] value = begin parse(`#{command}`, config) rescue nil end return key => value end |
.shell_state(config) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/chaoite/handler.rb', line 30 def shell_state config key = config["key"] command = config["check"] value = system(command) ? 1 : 0 return key => value end |