Class: MonitorType_Threshold

Inherits:
MonitorType show all
Defined in:
lib/MonitorType/Threshold.rb

Instance Method Summary collapse

Methods inherited from MonitorType

#alert, #process, #run, #sanitise

Constructor Details

#initialize(params) ⇒ MonitorType_Threshold



4
5
6
7
8
# File 'lib/MonitorType/Threshold.rb', line 4

def initialize( params )
       @min = params[:min] ||= 0
       @max = params[:max]
	super( params )
end

Instance Method Details

#check(value, context_sentence) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/MonitorType/Threshold.rb', line 10

def check( value, context_sentence )
       value = value.to_i
       if !@min.nil? && value < @min then
           self.alert( "#{context_sentence}\nMinimum threshold exceeded. Minimum: #{@min}, Actual: #{value}" )
       end
       if !@max.nil? && value > @max then
           self.alert( "#{context_sentence}\nMaximum threshold exceeded. Maximum: #{@max}, Actual: #{value}" )
       end
       
end