Skip to content

Commit

Permalink
Merge pull request #111 from scottjg/shut-up-god
Browse files Browse the repository at this point in the history
Don't log if processes are running and within bounds
  • Loading branch information
tmm1 committed Sep 17, 2012
2 parents 59cd9ed + 22139d7 commit ff74d98
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/god/conditions/cpu_usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def valid?
def test
process = System::Process.new(self.pid)
@timeline.push(process.percent_cpu)
self.info = []

history = "[" + @timeline.map { |x| "#{x > self.above ? '*' : ''}#{x}%%" }.join(", ") + "]"

if @timeline.select { |x| x > self.above }.size >= self.times.first
self.info = "cpu out of bounds #{history}"
return true
else
self.info = "cpu within bounds #{history}"
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/god/conditions/disk_usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def valid?
end

def test
self.info = []
usage = `df -P | grep -i " #{self.mount_point}$" | awk '{print $5}' | sed 's/%//'`
if usage.to_i > self.above
self.info = "disk space out of bounds"
return true
else
self.info = "disk space ok"
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/god/conditions/memory_usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ def valid?
def test
process = System::Process.new(self.pid)
@timeline.push(process.memory)
self.info = []

history = "[" + @timeline.map { |x| "#{x > self.above ? '*' : ''}#{x}kb" }.join(", ") + "]"

if @timeline.select { |x| x > self.above }.size >= self.times.first
self.info = "memory out of bounds #{history}"
return true
else
self.info = "memory within bounds #{history}"
return false
end
end
Expand Down
3 changes: 0 additions & 3 deletions lib/god/conditions/process_running.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ def test
active = pid && System::Process.new(pid).exists?

if (self.running && active)
self.info.concat(["process is running"])
true
elsif (!self.running && !active)
self.info.concat(["process is not running"])
true
else
if self.running
self.info.concat(["process is not running"])
else
self.info.concat(["process is running"])
end
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/god/conditions/socket_responding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def valid?
end

def test
self.info = []
if self.family == 'tcp'
begin
s = TCPSocket.new(self.addr, self.port)
Expand All @@ -123,7 +124,6 @@ def test
self.info = "socket out of bounds #{history}"
return true
else
self.info = "socket within bounds #{history}"
return false
end
end
Expand Down

0 comments on commit ff74d98

Please sign in to comment.