Class: MMS::Resource::Host
- Inherits:
-
MMS::Resource
- Object
- MMS::Resource
- MMS::Resource::Host
- Defined in:
- lib/mms/resource/host.rb
Instance Attribute Summary collapse
-
#alerts_enabled ⇒ Object
Returns the value of attribute alerts_enabled.
-
#host_enabled ⇒ Object
Returns the value of attribute host_enabled.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#last_ping ⇒ Object
Returns the value of attribute last_ping.
-
#logs_enabled ⇒ Object
Returns the value of attribute logs_enabled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
-
#profiler_enabled ⇒ Object
Returns the value of attribute profiler_enabled.
-
#replica_state_name ⇒ Object
Returns the value of attribute replica_state_name.
-
#replicaset_name ⇒ Object
Returns the value of attribute replicaset_name.
-
#shard_name ⇒ Object
Returns the value of attribute shard_name.
-
#type_name ⇒ Object
Returns the value of attribute type_name.
-
#version ⇒ Object
Returns the value of attribute version.
Attributes inherited from MMS::Resource
Class Method Summary collapse
Instance Method Summary collapse
- #group ⇒ MMS::Resource::Group
-
#initialize ⇒ Host
constructor
A new instance of Host.
- #metrics ⇒ Object
- #snapshot(id) ⇒ Object
- #snapshots(page = 1, limit = 1000) ⇒ Object
- #table_row ⇒ Object
- #table_section ⇒ Object
Methods inherited from MMS::Resource
#_load, find, #from_hash, #invalidate_cache, #set_client, #set_data, #to_hash
Constructor Details
#initialize ⇒ Host
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_enabled ⇒ Object
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_enabled ⇒ Object
Returns the value of attribute host_enabled.
16 17 18 |
# File 'lib/mms/resource/host.rb', line 16 def host_enabled @host_enabled end |
#hostname ⇒ Object
Returns the value of attribute hostname.
6 7 8 |
# File 'lib/mms/resource/host.rb', line 6 def hostname @hostname end |
#ip_address ⇒ Object
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_ping ⇒ Object
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_enabled ⇒ Object
Returns the value of attribute logs_enabled.
18 19 20 |
# File 'lib/mms/resource/host.rb', line 18 def logs_enabled @logs_enabled end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/mms/resource/host.rb', line 5 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/mms/resource/host.rb', line 7 def port @port end |
#profiler_enabled ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
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_name ⇒ Object
Returns the value of attribute type_name.
8 9 10 |
# File 'lib/mms/resource/host.rb', line 8 def type_name @type_name end |
#version ⇒ Object
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
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_header ⇒ Object
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
#group ⇒ MMS::Resource::Group
25 26 27 |
# File 'lib/mms/resource/host.rb', line 25 def group MMS::Resource::Group.find(@client, @data['groupId']) end |
#metrics ⇒ Object
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_row ⇒ Object
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_section ⇒ Object
50 51 52 |
# File 'lib/mms/resource/host.rb', line 50 def table_section [table_row] end |