Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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