class XymonClient::ServiceItemGauge

Public Class Methods

new(config) click to toggle source
Calls superclass method XymonClient::ServiceItem::new
# File lib/xymonclient/serviceitem.rb, line 72
def initialize(config)
  super(config)
  update_config(config)
end

Public Instance Methods

context() click to toggle source
Calls superclass method XymonClient::ServiceItem#context
# File lib/xymonclient/serviceitem.rb, line 102
def context
  {
    'nan_status' => @nan_status
  }.merge(super)
end
status() click to toggle source
# File lib/xymonclient/serviceitem.rb, line 77
def status
  @status = \
    if !@enabled
      'clear'
    elsif Time.now - @time > \
          XymonClient.timestring_to_time(@lifetime)
      'purple'
    elsif value.instance_of?(Float) && value.nan?
      @threshold.fetch('nan_status', 'red')
    elsif @threshold.key?('critical') && \
          _threshold_reached?('critical')
      'red'
    elsif @threshold.key?('warning') && \
          _threshold_reached?('warning')
      'yellow'
    else
      'green'
    end
end
update_config(config) click to toggle source
Calls superclass method XymonClient::ServiceItem#update_config
# File lib/xymonclient/serviceitem.rb, line 97
def update_config(config)
  super(config)
  @nan_status = config.fetch('nan_status', 'green')
end

Private Instance Methods

_threshold_reached?(threshold) click to toggle source
# File lib/xymonclient/serviceitem.rb, line 110
def _threshold_reached?(threshold)
  case @threshold.fetch('order', '<')
  when '<'
    @value < @threshold[threshold]
  when '>'
    @value > @threshold[threshold]
  when '<='
    @value <= @threshold[threshold]
  when '>='
    @value >= @threshold[threshold]
  end
end