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
- #_from_hash(data) ⇒ Object
- #_to_hash ⇒ Object
- #group ⇒ MMS::Resource::Group
-
#initialize ⇒ Host
constructor
A new instance of Host.
- #metrics ⇒ Array<MMS::Resource::Metric>
- #snapshot(id) ⇒ Object
- #snapshots(page = 1, limit = 100) ⇒ Object
- #table_row ⇒ Object
- #table_section ⇒ Object
Methods inherited from MMS::Resource
#_load, cache_key, find, #from_hash, #invalidate_cache, #to_hash
Constructor Details
#initialize ⇒ Host
Returns a new instance of Host.
18 19 20 |
# File 'lib/mms/resource/host.rb', line 18 def initialize @metric_list = [] end |
Instance Attribute Details
#alerts_enabled ⇒ Object
Returns the value of attribute alerts_enabled.
13 14 15 |
# File 'lib/mms/resource/host.rb', line 13 def alerts_enabled @alerts_enabled end |
#host_enabled ⇒ Object
Returns the value of attribute host_enabled.
14 15 16 |
# File 'lib/mms/resource/host.rb', line 14 def host_enabled @host_enabled end |
#hostname ⇒ Object
Returns the value of attribute hostname.
4 5 6 |
# File 'lib/mms/resource/host.rb', line 4 def hostname @hostname end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
8 9 10 |
# File 'lib/mms/resource/host.rb', line 8 def ip_address @ip_address end |
#last_ping ⇒ Object
Returns the value of attribute last_ping.
7 8 9 |
# File 'lib/mms/resource/host.rb', line 7 def last_ping @last_ping end |
#logs_enabled ⇒ Object
Returns the value of attribute logs_enabled.
16 17 18 |
# File 'lib/mms/resource/host.rb', line 16 def logs_enabled @logs_enabled end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/mms/resource/host.rb', line 3 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/mms/resource/host.rb', line 5 def port @port end |
#profiler_enabled ⇒ Object
Returns the value of attribute profiler_enabled.
15 16 17 |
# File 'lib/mms/resource/host.rb', line 15 def profiler_enabled @profiler_enabled end |
#replica_state_name ⇒ Object
Returns the value of attribute replica_state_name.
12 13 14 |
# File 'lib/mms/resource/host.rb', line 12 def replica_state_name @replica_state_name end |
#replicaset_name ⇒ Object
Returns the value of attribute replicaset_name.
11 12 13 |
# File 'lib/mms/resource/host.rb', line 11 def replicaset_name @replicaset_name end |
#shard_name ⇒ Object
Returns the value of attribute shard_name.
10 11 12 |
# File 'lib/mms/resource/host.rb', line 10 def shard_name @shard_name end |
#type_name ⇒ Object
Returns the value of attribute type_name.
6 7 8 |
# File 'lib/mms/resource/host.rb', line 6 def type_name @type_name end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/mms/resource/host.rb', line 9 def version @version end |
Class Method Details
._find(client, group_id, id) ⇒ Hash
60 61 62 |
# File 'lib/mms/resource/host.rb', line 60 def self._find(client, group_id, id) client.get('/groups/' + group_id + '/hosts/' + id) end |
.table_header ⇒ Object
52 53 54 |
# File 'lib/mms/resource/host.rb', line 52 def self.table_header ['Group', 'Type', 'Hostname', 'IP', 'Port', 'Last ping', 'Alerts enabled', 'HostId', 'Shard', 'Replica'] end |
Instance Method Details
#_from_hash(data) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mms/resource/host.rb', line 78 def _from_hash(data) @hostname = data['hostname'] @port = data['port'] @type_name = data['typeName'] @last_ping = data['lastPing'] @ip_address = data['ipAddress'] @version = data['version'] @shard_name = data['shardName'] @replicaset_name = data['replicaSetName'] @replica_state_name = data['replicaStateName'] @alerts_enabled = data['alertsEnabled'] @host_enabled = data['hostEnabled'] @profiler_enabled = data['profilerEnabled'] @logs_enabled = data['logsEnabled'] @name = @hostname end |
#_to_hash ⇒ Object
95 96 97 |
# File 'lib/mms/resource/host.rb', line 95 def _to_hash @data end |
#group ⇒ MMS::Resource::Group
23 24 25 |
# File 'lib/mms/resource/host.rb', line 23 def group MMS::Resource::Group.find(@client, @data['groupId']) end |
#metrics ⇒ Array<MMS::Resource::Metric>
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mms/resource/host.rb', line 65 def metrics if @metric_list.empty? @client.get('/groups/' + group.id + '/hosts/' + @id + '/metrics').each do |metric| m = MMS::Resource::Metric.new m.client(@client) m.data(metric) @metric_list.push m end end @metric_list end |
#snapshot(id) ⇒ Object
27 28 29 |
# File 'lib/mms/resource/host.rb', line 27 def snapshot(id) MMS::Resource::Snapshot.find(@client, group.id, nil, @id, id) end |
#snapshots(page = 1, limit = 100) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mms/resource/host.rb', line 31 def snapshots(page = 1, limit = 100) 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.client(@client) s.data(snapshot) @snapshots.push s end end @snapshots end |
#table_row ⇒ Object
44 45 46 |
# File 'lib/mms/resource/host.rb', line 44 def table_row [group.name, @type_name, @name, @ip_address, @port, @last_ping, @alerts_enabled, @id, @shard_name, @replicaset_name] end |
#table_section ⇒ Object
48 49 50 |
# File 'lib/mms/resource/host.rb', line 48 def table_section [table_row] end |