Class: Mackerel::Host

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

Constant Summary collapse

MACKEREL_INTERFACE_NAME_PATTERN =
/^eth\d/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Host

Returns a new instance of Host.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mackerel/host.rb', line 8

def initialize(args = {})
  @hash             = args
  @name             = args["name"]
  @meta             = args["meta"]
  @size             = args["size"]
  @status           = args["status"]
  @memo             = args["memo"]
  @isRetired        = args["isRetired"]
  @id               = args["id"]
  @createdAt        = args["createdAt"]
  @roles            = args["roles"]
  @interfaces       = args["interfaces"]
  @customIdentifier = args["customIdentifier"]
end

Instance Attribute Details

#createdAtObject

Returns the value of attribute createdAt.



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

def createdAt
  @createdAt
end

#customIdentifierObject

Returns the value of attribute customIdentifier.



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

def customIdentifier
  @customIdentifier
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#interfacesObject

Returns the value of attribute interfaces.



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

def interfaces
  @interfaces
end

#isRetiredObject

Returns the value of attribute isRetired.



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

def isRetired
  @isRetired
end

#memoObject

Returns the value of attribute memo.



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

def memo
  @memo
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#rolesObject

Returns the value of attribute roles.



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

def roles
  @roles
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#ip_addrObject



23
24
25
26
27
28
# File 'lib/mackerel/host.rb', line 23

def ip_addr
  interface = @interfaces.find do |i|
    MACKEREL_INTERFACE_NAME_PATTERN === i['name']
  end
  interface['ipAddress'] if interface
end

#mac_addrObject



30
31
32
33
34
35
# File 'lib/mackerel/host.rb', line 30

def mac_addr
  interface = @interfaces.find do |i|
    MACKEREL_INTERFACE_NAME_PATTERN === i['name']
  end
  interface['macAddress'] if interface
end

#to_hObject



37
38
39
# File 'lib/mackerel/host.rb', line 37

def to_h
  return @hash
end