Class: Mackerel::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/mackerel/monitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Monitor

Returns a new instance of Monitor.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mackerel/monitor.rb', line 7

def initialize(args = {})
  @id                              = args["id"]
  @type                            = args["type"]
  @name                            = args["name"]
  @duration                        = args["duration"]
  @metric                          = args["metric"]
  @url                             = args["url"]
  @service                         = args["service"]
  @maxCheckAttempts                = args["maxCheckAttempts"]
  @operator                        = args["operator"]
  @warning                         = args["warning"]
  @critical                        = args["critical"]
  @responseTimeWarning             = args["responseTimeWarning"]
  @responseTimeCritical            = args["responseTimeCritical"]
  @responseTimeDuration            = args["responseTimeDuration"]
  @certificationExpirationWarning  = args["certificationExpirationWarning"]
  @certificationExpirationCritical = args["certificationExpirationCritical"]
  @containsString                  = args["containsString"]
  @expression                      = args["expression"]
  @notificationInterval            = args["notificationInterval"]
  @scopes                          = args["scopes"]
  @excludeScopes                   = args["excludeScopes"]
  @isMute                          = args["isMute"]
end

Instance Attribute Details

#certificationExpirationCriticalObject

Returns the value of attribute certificationExpirationCritical.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def certificationExpirationCritical
  @certificationExpirationCritical
end

#certificationExpirationWarningObject

Returns the value of attribute certificationExpirationWarning.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def certificationExpirationWarning
  @certificationExpirationWarning
end

#containsStringObject

Returns the value of attribute containsString.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def containsString
  @containsString
end

#criticalObject

Returns the value of attribute critical.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def critical
  @critical
end

#durationObject

Returns the value of attribute duration.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def duration
  @duration
end

#excludeScopesObject

Returns the value of attribute excludeScopes.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def excludeScopes
  @excludeScopes
end

#expressionObject

Returns the value of attribute expression.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def expression
  @expression
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def id
  @id
end

#isMuteObject

Returns the value of attribute isMute.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def isMute
  @isMute
end

#maxCheckAttemptsObject

Returns the value of attribute maxCheckAttempts.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def maxCheckAttempts
  @maxCheckAttempts
end

#metricObject

Returns the value of attribute metric.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def metric
  @metric
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def name
  @name
end

#notificationIntervalObject

Returns the value of attribute notificationInterval.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def notificationInterval
  @notificationInterval
end

#operatorObject

Returns the value of attribute operator.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def operator
  @operator
end

#responseTimeCriticalObject

Returns the value of attribute responseTimeCritical.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def responseTimeCritical
  @responseTimeCritical
end

#responseTimeDurationObject

Returns the value of attribute responseTimeDuration.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def responseTimeDuration
  @responseTimeDuration
end

#responseTimeWarningObject

Returns the value of attribute responseTimeWarning.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def responseTimeWarning
  @responseTimeWarning
end

#scopesObject

Returns the value of attribute scopes.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def scopes
  @scopes
end

#serviceObject

Returns the value of attribute service.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def service
  @service
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def type
  @type
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def url
  @url
end

#warningObject

Returns the value of attribute warning.



5
6
7
# File 'lib/mackerel/monitor.rb', line 5

def warning
  @warning
end

Instance Method Details

#to_hObject



32
33
34
35
36
37
38
# File 'lib/mackerel/monitor.rb', line 32

def to_h
  instance_variables.flat_map do |name|
    respond_to?(name[1..-1]) ? [name[1..-1]] : []
  end.each_with_object({}) do |name, hash|
    hash[name] = public_send(name)
  end.delete_if { |key, val| val == nil }
end

#to_json(options = nil) ⇒ Object



40
41
42
# File 'lib/mackerel/monitor.rb', line 40

def to_json(options = nil)
  return to_h.to_json(options)
end