class MMS::Resource::Host

Attributes

alerts_enabled[RW]
host_enabled[RW]
hostname[RW]
ip_address[RW]
last_ping[RW]
logs_enabled[RW]
name[RW]
port[RW]
profiler_enabled[RW]
replica_state_name[RW]
replicaset_name[RW]
shard_name[RW]
type_name[RW]
version[RW]

Public Class Methods

_find(client, group_id, id) click to toggle source

@param [MMS::Client] client @param [String] group_id @param [String] id @return [Hash]

# File lib/mms/resource/host.rb, line 60
def self._find(client, group_id, id)
  client.get('/groups/' + group_id + '/hosts/' + id)
end
new() click to toggle source
# File lib/mms/resource/host.rb, line 18
def initialize
  @metric_list = []
end
table_header() click to toggle source
# 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

Public Instance Methods

_from_hash(data) click to toggle source
# 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() click to toggle source
# File lib/mms/resource/host.rb, line 95
def _to_hash
  @data
end
group() click to toggle source

@return [MMS::Resource::Group]

# File lib/mms/resource/host.rb, line 23
def group
  MMS::Resource::Group.find(@client, @data['groupId'])
end
metrics() click to toggle source

@return [Array<MMS::Resource::Metric>]

# 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) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/mms/resource/host.rb, line 48
def table_section
  [table_row]
end