Class: XymonClient::ServiceItem
- Inherits:
-
Object
- Object
- XymonClient::ServiceItem
- Defined in:
- lib/xymonclient/serviceitem.rb
Overview
Manage an item to monitor
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#description ⇒ Object
Returns the value of attribute description.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#label ⇒ Object
Returns the value of attribute label.
-
#lifetime ⇒ Object
Returns the value of attribute lifetime.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #context ⇒ Object
-
#initialize(config) ⇒ ServiceItem
constructor
A new instance of ServiceItem.
- #update_config(config) ⇒ Object
Constructor Details
#initialize(config) ⇒ ServiceItem
Returns a new instance of ServiceItem.
17 18 19 20 21 22 23 |
# File 'lib/xymonclient/serviceitem.rb', line 17 def initialize(config) raise InvalidServiceItemName if config.fetch('label', '') == '' @time = Time.at(0) @threshold = config.fetch('threshold', {}) @attributes = config.fetch('attributes', {}) update_config(config) end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/xymonclient/serviceitem.rb', line 9 def attributes @attributes end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/xymonclient/serviceitem.rb', line 11 def description @description end |
#enabled ⇒ Object
Returns the value of attribute enabled.
10 11 12 |
# File 'lib/xymonclient/serviceitem.rb', line 10 def enabled @enabled end |
#label ⇒ Object
Returns the value of attribute label.
13 14 15 |
# File 'lib/xymonclient/serviceitem.rb', line 13 def label @label end |
#lifetime ⇒ Object
Returns the value of attribute lifetime.
12 13 14 |
# File 'lib/xymonclient/serviceitem.rb', line 12 def lifetime @lifetime end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
14 15 16 |
# File 'lib/xymonclient/serviceitem.rb', line 14 def status @status end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
15 16 17 |
# File 'lib/xymonclient/serviceitem.rb', line 15 def time @time end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/xymonclient/serviceitem.rb', line 8 def value @value end |
Instance Method Details
#context ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/xymonclient/serviceitem.rb', line 55 def context { 'label' => @label, 'description' => @description, 'enabled' => @enabled, 'lifetime' => @lifetime, 'timestamp' => @timestamp, 'threshold' => @threshold, 'attributes' => @attributes, 'status' => @status, 'value' => @value } end |
#update_config(config) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/xymonclient/serviceitem.rb', line 45 def update_config(config) raise InvalidServiceItemName if config.fetch('label', '') == '' @label = config['label'] @description = config.fetch('description', '') @enabled = config.fetch('enabled', true) @lifetime = config.fetch('lifetime', '30m') @threshold = config.fetch('threshold', {}) @attributes.merge!(config.fetch('attributes', {})) end |