Class: Mackerel::Host
- Inherits:
-
Object
- Object
- Mackerel::Host
- Defined in:
- lib/mackerel/host.rb
Constant Summary collapse
- MACKEREL_INTERFACE_NAME_PATTERN =
/^eth\d/
Instance Attribute Summary collapse
-
#createdAt ⇒ Object
Returns the value of attribute createdAt.
-
#customIdentifier ⇒ Object
Returns the value of attribute customIdentifier.
-
#id ⇒ Object
Returns the value of attribute id.
-
#interfaces ⇒ Object
Returns the value of attribute interfaces.
-
#isRetired ⇒ Object
Returns the value of attribute isRetired.
-
#memo ⇒ Object
Returns the value of attribute memo.
-
#name ⇒ Object
Returns the value of attribute name.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#size ⇒ Object
Returns the value of attribute size.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Host
constructor
A new instance of Host.
- #ip_addr ⇒ Object
- #mac_addr ⇒ Object
- #to_h ⇒ Object
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
#createdAt ⇒ Object
Returns the value of attribute createdAt.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def createdAt @createdAt end |
#customIdentifier ⇒ Object
Returns the value of attribute customIdentifier.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def customIdentifier @customIdentifier end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def id @id end |
#interfaces ⇒ Object
Returns the value of attribute interfaces.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def interfaces @interfaces end |
#isRetired ⇒ Object
Returns the value of attribute isRetired.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def isRetired @isRetired end |
#memo ⇒ Object
Returns the value of attribute memo.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def memo @memo end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def name @name end |
#roles ⇒ Object
Returns the value of attribute roles.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def roles @roles end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def size @size end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def status @status end |
Instance Method Details
#ip_addr ⇒ Object
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_addr ⇒ Object
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_h ⇒ Object
37 38 39 |
# File 'lib/mackerel/host.rb', line 37 def to_h return @hash end |