Sha256: b70925b63af113d8f0d59430d7da6e14ba8b2c44b14d351d99efc0a7a5ebeb08

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

module RRDNotifier
  ##
  # An active alarm.
  # 
  class Alarm
    # the packet which triggered the alarm
    attr_accessor :packet
    
    def initialize(p)
      @packet = p
    end
    
    def method_missing(m, *args)
      if packet
        packet.send(m, *args)
      end
    end
  end
  
  class AlarmTooHigh < Alarm
    def reason; :too_high; end
    
    attr_accessor :threshold
    
    def initialize(p, threshold)
      super(p)
      @threshold = threshold
    end
    
    def is_same?(threshold)
      @threshold == threshold
    end
  end
  
  class AlarmTooLow < AlarmTooHigh
    def reason; :too_low; end
  end
  
  class AlarmMissingData < Alarm
    def reason; :missing_data; end
    
    ##
    # Time allowed between updates.
    attr_accessor :allowed_interval
    
    ##
    # When was this measure last updated ?
    attr_accessor :last_update
    
    def initialize(p, allowed_interval ,last_update)
      super(p)
      @allowed_interval = allowed_interval
      @last_update = last_update
    end
    
    def is_same?(allowed_interval ,last_update)
      (@allowed_interval == allowed_interval) &&
      (@last_update == last_update)
    end
  end
  
  class AlarmClockDrift < Alarm
    def reason; :clock_drift; end
    
    # difference in seconds between our clock
    # and the one of the host
    attr_accessor :allowed_drift
    
    def initialize(p, allowed_drift)
      super(p)
      @allowed_drift = allowed_drift
    end
    
    def is_same?(drift)
      @allowed_drift == drift
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rrd-grapher-1.0.3 lib/rrd-grapher/notifier/alarms.rb
rrd-grapher-1.0.2 lib/rrd-grapher/notifier/alarms.rb
rrd-grapher-1.0.1 lib/rrd-grapher/notifier/alarms.rb
rrd-grapher-1.0.0 lib/rrd-grapher/notifier/alarms.rb