Class: XymonClient::ServiceItemString

Inherits:
ServiceItem show all
Defined in:
lib/xymonclient/serviceitem.rb

Instance Attribute Summary

Attributes inherited from ServiceItem

#info, #value

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ServiceItemString

Returns a new instance of ServiceItemString.



95
96
97
98
# File 'lib/xymonclient/serviceitem.rb', line 95

def initialize(config)
  super(config)
  @info['threshold'] = config.fetch('threshold', {})
end

Instance Method Details

#statusObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/xymonclient/serviceitem.rb', line 100

def status
  @info['status'] = \
    if !@info['enabled']
      'clear'
    elsif Time.now - @info['time'] > \
          XymonClient.timestring_to_time(@info['lifetime'])
      'purple'
    elsif @info['threshold'].key?('critical') && \
          _threshold_reached?('critical')
      'red'
    elsif @info['threshold'].key?('warning') && \
          _threshold_reached?('warning')
      'yellow'
    else
      'green'
    end
end