Class: Remon::Check
Direct Known Subclasses
Constant Summary collapse
- WARNING =
"warning".freeze
- CRITICAL =
"critical".freeze
- OK =
"ok".freeze
Instance Attribute Summary collapse
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#opts ⇒ Object
(also: #o)
readonly
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
- #check_name ⇒ Object
-
#initialize(*args, **kwargs, &block) ⇒ Check
constructor
A new instance of Check.
- #run ⇒ Object
- #run_mutex ⇒ Object
- #to_s ⇒ Object
Methods included from Logger
Constructor Details
#initialize(*args, **kwargs, &block) ⇒ Check
Returns a new instance of Check.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/remon/check.rb', line 29 def initialize(*args, **kwargs, &block) @tags = kwargs[:tags] || [] @ttl = kwargs[:ttl] || 10 @host = kwargs[:host] || Remon.host opts = kwargs[:opts] || {} verfiy_opts(opts) default_opts = self.class.get_opts @opts = default_opts.merge opts @mutex = Mutex.new return if not respond_to? :init # propagate only those kwargs which are defined in "init" method definition filtered_kwargs = filtered_kwargs(kwargs) #workaround a bug in ruby for methods that take 0 args if filtered_kwargs.empty? init(*args, &block) if respond_to? :init else init(*args, **filtered_kwargs, &block) if respond_to? :init end end |
Instance Attribute Details
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
25 26 27 |
# File 'lib/remon/check.rb', line 25 def mutex @mutex end |
#opts ⇒ Object (readonly) Also known as: o
Returns the value of attribute opts.
25 26 27 |
# File 'lib/remon/check.rb', line 25 def opts @opts end |
Class Method Details
.get_opts ⇒ Object
17 18 19 |
# File 'lib/remon/check.rb', line 17 def self.get_opts @opts ||= {} end |
.name ⇒ Object
5 6 7 |
# File 'lib/remon/check.rb', line 5 def self.name @name || "undefined" end |
.name=(name) ⇒ Object
9 10 11 |
# File 'lib/remon/check.rb', line 9 def self.name=(name) @name = name end |
.opts(h) ⇒ Object
13 14 15 |
# File 'lib/remon/check.rb', line 13 def self.opts(h) @opts = h end |
Instance Method Details
#check_name ⇒ Object
61 62 63 |
# File 'lib/remon/check.rb', line 61 def check_name self.class.name end |
#run ⇒ Object
53 54 55 |
# File 'lib/remon/check.rb', line 53 def run raise NotImplementedError.new "run method not implemented" end |
#run_mutex ⇒ Object
57 58 59 |
# File 'lib/remon/check.rb', line 57 def run_mutex synchronize { run } end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/remon/check.rb', line 65 def to_s "<check:#{check_name}>" end |