Skip to content

Commit

Permalink
Merge tag 'v0.13.1' into mgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
icy committed Nov 6, 2012
2 parents 147ec3e + b0257b3 commit 475eab7
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 16 deletions.
12 changes: 10 additions & 2 deletions History.txt
@@ -1,8 +1,16 @@
== 0.12.1
== 0.13.1 / 2012-09-18
* Minor Changes
* Prevent auto-loading from bundler by requiring $load_god to require (#97)

== 0.13.0 / 2012-09-17
* Minor Changes
* Reduce verbosity of non-failing conditions (#111)

== 0.12.1 / 2012-01-21
* Bug Fixes
* Fix undefined variable problem in CLI (#82)

== 0.12.0
== 0.12.0 / 2012-01-13
* Minor Enhancements
* Add umask support
* Add socket response condition (#25)
Expand Down
4 changes: 3 additions & 1 deletion bin/god
Expand Up @@ -4,7 +4,6 @@ STDOUT.sync = true

$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])

require 'rubygems'
require 'optparse'
require 'drb'
require 'yaml'
Expand Down Expand Up @@ -105,6 +104,9 @@ begin
abort("Invalid log level '#{options[:log_level]}'")
end

# Use this flag to actually load all of the god infrastructure
$load_god = true

# dispatch
if !options[:config] && options[:version]
require 'god'
Expand Down
4 changes: 2 additions & 2 deletions god.gemspec
Expand Up @@ -3,8 +3,8 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=

s.name = 'god'
s.version = '0.12.1'
s.date = '2012-01-21'
s.version = '0.13.1'
s.date = '2012-09-18'

s.summary = "Process monitoring framework."
s.description = "An easy to configure, easy to extend monitoring framework written in Ruby."
Expand Down
12 changes: 9 additions & 3 deletions lib/god.rb
@@ -1,4 +1,8 @@
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
# Bail out before loading anything unless this flag is set.
#
# We are doing this to guard against bundler autoloading because there is
# no value in loading god in most processes.
if $load_god

# core
require 'stringio'
Expand Down Expand Up @@ -151,7 +155,7 @@ def safe_attr_accessor(*args)

module God
# The String version number for this package.
VERSION = '0.12.1'
VERSION = '0.13.1'

# The Integer number of lines of backlog to keep for the logger.
LOG_BUFFER_SIZE_DEFAULT = 100
Expand Down Expand Up @@ -726,7 +730,7 @@ def self.at_exit
# private

# Match a shortened pattern against a list of String candidates.
# The pattern is expanded into a regular expression by
# The pattern is expanded into a regular expression by
# inserting .* between each character.
#
# pattern - The String containing the abbreviation.
Expand Down Expand Up @@ -756,3 +760,5 @@ def self.pattern_match(pattern, list)
at_exit do
God.at_exit if $run
end

end
2 changes: 1 addition & 1 deletion lib/god/conditions/cpu_usage.rb
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
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
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
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
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
6 changes: 5 additions & 1 deletion test/helper.rb
@@ -1,4 +1,8 @@
require 'rubygems'
$:.unshift File.expand_path('../../lib', __FILE__) # For use/testing when no gem is installed

# Use this flag to actually load all of the god infrastructure
$load_god = true

require File.join(File.dirname(__FILE__), *%w[.. lib god sys_logger])
require File.join(File.dirname(__FILE__), *%w[.. lib god])
God::EventHandler.load
Expand Down

0 comments on commit 475eab7

Please sign in to comment.