4 class MemoryUsage < Condition
5 attr_accessor :pid_file, :above, :times
14 if self.times.kind_of?(Integer)
15 self.times = [self.times, self.times]
18 @timeline = Timeline.new(self.times[1])
23 valid &= complain("You must specify the 'pid_file' attribute for :memory_usage") if self.pid_file.nil?
24 valid &= complain("You must specify the 'above' attribute for :memory_usage") if self.above.nil?
29 return false unless File.exist?(self.pid_file)
31 pid = File.open(self.pid_file).read.strip
32 process = System::Process.new(pid)
33 @timeline.push(process.memory)
34 if @timeline.select { |x| x > self.above }.size < self.times.first