Sha256: d660965564d88956ee18af2d513253220cf9f20f945e72de4f1355b458c981f3
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
module God module Conditions class MemoryUsage < PollCondition attr_accessor :above, :times def initialize super self.above = nil self.times = [1, 1] end def prepare if self.times.kind_of?(Integer) self.times = [self.times, self.times] end @timeline = Timeline.new(self.times[1]) end def valid? valid = true valid &= complain("You must specify the 'pid_file' attribute on the Watch for :memory_usage") if self.watch.pid_file.nil? valid &= complain("You must specify the 'above' attribute for :memory_usage") if self.above.nil? valid end def test return false unless File.exist?(self.watch.pid_file) pid = File.read(self.watch.pid_file).strip process = System::Process.new(pid) @timeline.push(process.memory) if @timeline.select { |x| x > self.above }.size >= self.times.first @timeline.clear return true else return false end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
god-0.3.0 | lib/god/conditions/memory_usage.rb |
god-0.4.0 | lib/god/conditions/memory_usage.rb |
god-0.4.1 | lib/god/conditions/memory_usage.rb |
god-0.4.3 | lib/god/conditions/memory_usage.rb |