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.
-
#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.
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
Returns the value of attribute type.
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 |
# File 'lib/mackerel/host.rb', line 8 def initialize(args = {}) @hash = args @name = args["name"] @meta = args["meta"] @type = args["type"] @status = args["status"] @memo = args["memo"] @isRetired = args["isRetired"] @id = args["id"] @createdAt = args["createdAt"] @roles = args["roles"] @interfaces = args["interfaces"] 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 |
#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 |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def status @status end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/mackerel/host.rb', line 6 def type @type end |
Instance Method Details
#ip_addr ⇒ Object
22 23 24 25 26 27 |
# File 'lib/mackerel/host.rb', line 22 def ip_addr interface = @interfaces.find do |i| MACKEREL_INTERFACE_NAME_PATTERN === i['name'] end interface['ipAddress'] if interface end |
#mac_addr ⇒ Object
29 30 31 32 33 34 |
# File 'lib/mackerel/host.rb', line 29 def mac_addr interface = @interfaces.find do |i| MACKEREL_INTERFACE_NAME_PATTERN === i['name'] end interface['macAddress'] if interface end |
#to_h ⇒ Object
36 37 38 |
# File 'lib/mackerel/host.rb', line 36 def to_h return @hash end |