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
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(config) ⇒ ServiceItem
constructor
A new instance of ServiceItem.
- #status ⇒ Object
Constructor Details
#initialize(config) ⇒ ServiceItem
Returns a new instance of ServiceItem.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xymonclient/serviceitem.rb', line 11 def initialize(config) raise InvalidServiceItemName if config.fetch('label', '') == '' @info = { 'label' => config['label'], 'type' => config['type'], 'description' => config.fetch('description', ''), 'enabled' => config.fetch('enabled', true), 'status' => 'purple', 'lifetime' => config.fetch('lifetime', '30m'), 'time' => Time.at(0) } end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
9 10 11 |
# File 'lib/xymonclient/serviceitem.rb', line 9 def info @info 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
#status ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/xymonclient/serviceitem.rb', line 34 def status @info['status'] = \ if !@info['enabled'] 'clear' elsif Time.now - @info['time'] > \ XymonClient.timestring_to_time(@info['lifetime']) 'purple' elsif XymonClient.valid_status?(@info['value']) @info['value'] else 'red' end end |