Class: MMS::Resource::Host

Inherits:
MMS::Resource show all
Defined in:
lib/mms/resource/host.rb

Instance Attribute Summary collapse

Attributes inherited from MMS::Resource

#client, #data, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MMS::Resource

#_load, find, #from_hash, #invalidate_cache, #set_client, #set_data, #to_hash

Constructor Details

#initializeHost

Returns a new instance of Host.



20
21
22
# File 'lib/mms/resource/host.rb', line 20

def initialize
  @metric_list = []
end

Instance Attribute Details

#alerts_enabledObject

Returns the value of attribute alerts_enabled.



15
16
17
# File 'lib/mms/resource/host.rb', line 15

def alerts_enabled
  @alerts_enabled
end

#host_enabledObject

Returns the value of attribute host_enabled.



16
17
18
# File 'lib/mms/resource/host.rb', line 16

def host_enabled
  @host_enabled
end

#hostnameObject

Returns the value of attribute hostname.



6
7
8
# File 'lib/mms/resource/host.rb', line 6

def hostname
  @hostname
end

#ip_addressObject

Returns the value of attribute ip_address.



10
11
12
# File 'lib/mms/resource/host.rb', line 10

def ip_address
  @ip_address
end

#last_pingObject

Returns the value of attribute last_ping.



9
10
11
# File 'lib/mms/resource/host.rb', line 9

def last_ping
  @last_ping
end

#logs_enabledObject

Returns the value of attribute logs_enabled.



18
19
20
# File 'lib/mms/resource/host.rb', line 18

def logs_enabled
  @logs_enabled
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/mms/resource/host.rb', line 5

def name
  @name
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/mms/resource/host.rb', line 7

def port
  @port
end

#profiler_enabledObject

Returns the value of attribute profiler_enabled.



17
18
19
# File 'lib/mms/resource/host.rb', line 17

def profiler_enabled
  @profiler_enabled
end

#replica_state_nameObject

Returns the value of attribute replica_state_name.



14
15
16
# File 'lib/mms/resource/host.rb', line 14

def replica_state_name
  @replica_state_name
end

#replicaset_nameObject

Returns the value of attribute replicaset_name.



13
14
15
# File 'lib/mms/resource/host.rb', line 13

def replicaset_name
  @replicaset_name
end

#shard_nameObject

Returns the value of attribute shard_name.



12
13
14
# File 'lib/mms/resource/host.rb', line 12

def shard_name
  @shard_name
end

#type_nameObject

Returns the value of attribute type_name.



8
9
10
# File 'lib/mms/resource/host.rb', line 8

def type_name
  @type_name
end

#versionObject

Returns the value of attribute version.



11
12
13
# File 'lib/mms/resource/host.rb', line 11

def version
  @version
end

Class Method Details

._find(client, group_id, id) ⇒ Object

Parameters:



62
63
64
# File 'lib/mms/resource/host.rb', line 62

def self._find(client, group_id, id)
  client.get('/groups/' + group_id + '/hosts/' + id)
end

.table_headerObject



54
55
56
# File 'lib/mms/resource/host.rb', line 54

def self.table_header
  ['Group', 'Type', 'Hostname', 'IP', 'Port', 'Last ping', 'Alerts enabled', 'HostId', 'Shard', 'Replica']
end

Instance Method Details

#groupMMS::Resource::Group



25
26
27
# File 'lib/mms/resource/host.rb', line 25

def group
  MMS::Resource::Group.find(@client, @data['groupId'])
end

#metricsObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/mms/resource/host.rb', line 67

def metrics
  if @metric_list.empty?
    @client.get('/groups/' + group.id + '/hosts/' + @id + '/metrics').each do |metric|
      m = MMS::Resource::Metric.new
      m.set_client(@client)
      m.set_data(metric)

      @metric_list.push m
    end
  end
  @metric_list
end

#snapshot(id) ⇒ Object



29
30
31
# File 'lib/mms/resource/host.rb', line 29

def snapshot(id)
  MMS::Resource::Snapshot.find(@client, group.id, nil, @id, id)
end

#snapshots(page = 1, limit = 1000) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mms/resource/host.rb', line 33

def snapshots(page = 1, limit = 1000)
  if @snapshots.empty?
    @client.get('/groups/' + group.id + '/hosts/' + @id + '/snapshots?pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |snapshot|
      s = MMS::Resource::Snapshot.new
      s.set_client(@client)
      s.set_data(snapshot)

      @snapshots.push s
    end
  end
  @snapshots
end

#table_rowObject



46
47
48
# File 'lib/mms/resource/host.rb', line 46

def table_row
  [group.name, @type_name, @name, @ip_address, @port, @last_ping, @alerts_enabled, @id, @shard_name, @replicaset_name]
end

#table_sectionObject



50
51
52
# File 'lib/mms/resource/host.rb', line 50

def table_section
  [table_row]
end