class XymonClient::ServiceItemString

Public Instance Methods

status() click to toggle source
# File lib/xymonclient/serviceitem.rb, line 126
def status
  @status = \
    if !@enabled
      'clear'
    elsif Time.now - @time > \
          XymonClient.timestring_to_time(@lifetime)
      'purple'
    elsif @threshold.key?('critical') && \
          _threshold_reached?('critical')
      'red'
    elsif @threshold.key?('warning') && \
          _threshold_reached?('warning')
      'yellow'
    else
      'green'
    end
end

Private Instance Methods

_threshold_reached?(threshold) click to toggle source
# File lib/xymonclient/serviceitem.rb, line 146
def _threshold_reached?(threshold)
  inclusive = @threshold.fetch('inclusive', true)
  values = @value
  if values.instance_of?(Array)
    value_is_included = values.any? do |value|
      @threshold[threshold].include?(value)
    end
  else
    value_is_included = @threshold[threshold].include?(values)
  end
  (inclusive && value_is_included) || (!inclusive && !value_is_included)
end