From 85319ca3d467b4874b585df2b8904b35a3e9a89d Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Fri, 2 Nov 2007 20:06:14 -0400 Subject: [PATCH] additional condition rdoc --- lib/god/conditions/cpu_usage.rb | 27 +++++++++++++++++++++++++++ lib/god/conditions/flapping.rb | 8 +++++++- lib/god/conditions/memory_usage.rb | 31 ++++++++++++++++++++++++++++++- lib/god/conditions/process_exits.rb | 21 +++++++++++++++++++++ lib/god/conditions/process_running.rb | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+), 2 deletions(-) diff --git a/lib/god/conditions/cpu_usage.rb b/lib/god/conditions/cpu_usage.rb index 44a8744..f87ae5d 100644 --- a/lib/god/conditions/cpu_usage.rb +++ b/lib/god/conditions/cpu_usage.rb @@ -1,6 +1,33 @@ module God module Conditions + # Condition Symbol :cpu_usage + # Type: Poll + # + # Trigger when the percent of CPU use of a process is above a specified limit. + # On multi-core systems, this number could conceivably be above 100. + # + # Paramaters + # Required + # +pid_file+ is the pid file of the process in question. Automatically + # populated for Watches. + # +above+ is the percent CPU above which to trigger the condition. You + # may use #percent to clarify this amount (see examples). + # + # Examples + # + # Trigger if the process is using more than 25 percent of the cpu (from a Watch): + # + # on.condition(:cpu_usage) do |c| + # c.above = 25.percent + # end + # + # Non-Watch Tasks must specify a PID file: + # + # on.condition(:cpu_usage) do |c| + # c.above = 25.percent + # c.pid_file = "/var/run/mongrel.3000.pid" + # end class CpuUsage < PollCondition attr_accessor :above, :times diff --git a/lib/god/conditions/flapping.rb b/lib/god/conditions/flapping.rb index 1b06098..0fcf4ac 100644 --- a/lib/god/conditions/flapping.rb +++ b/lib/god/conditions/flapping.rb @@ -2,7 +2,13 @@ module God module Conditions class Flapping < TriggerCondition - attr_accessor :times, :within, :from_state, :to_state, :retry_in, :retry_times, :retry_within + attr_accessor :times, + :within, + :from_state, + :to_state, + :retry_in, + :retry_times, + :retry_within def initialize self.info = "process is flapping" diff --git a/lib/god/conditions/memory_usage.rb b/lib/god/conditions/memory_usage.rb index ebdf44b..4facc75 100644 --- a/lib/god/conditions/memory_usage.rb +++ b/lib/god/conditions/memory_usage.rb @@ -1,9 +1,38 @@ module God module Conditions + # Condition Symbol :memory_usage + # Type: Poll + # + # Trigger when the resident memory of a process is above a specified limit. + # + # Paramaters + # Required + # +pid_file+ is the pid file of the process in question. Automatically + # populated for Watches. + # +above+ is the amount of resident memory (in kilobytes) above which + # the condition should trigger. You can also use the sugar + # methods #kilobytes, #megabytes, and #gigabytes to clarify + # this amount (see examples). + # + # Examples + # + # Trigger if the process is using more than 100 megabytes of resident + # memory (from a Watch): + # + # on.condition(:memory_usage) do |c| + # c.above = 100.megabytes + # end + # + # Non-Watch Tasks must specify a PID file: + # + # on.condition(:memory_usage) do |c| + # c.above = 100.megabytes + # c.pid_file = "/var/run/mongrel.3000.pid" + # end class MemoryUsage < PollCondition attr_accessor :above, :times - + def initialize super self.above = nil diff --git a/lib/god/conditions/process_exits.rb b/lib/god/conditions/process_exits.rb index 787df20..1c1e06d 100644 --- a/lib/god/conditions/process_exits.rb +++ b/lib/god/conditions/process_exits.rb @@ -1,6 +1,27 @@ module God module Conditions + # Condition Symbol :process_exits + # Type: Event + # + # Trigger when a process exits. + # + # Paramaters + # Required + # +pid_file+ is the pid file of the process in question. Automatically + # populated for Watches. + # + # Examples + # + # Trigger if process exits (from a Watch): + # + # on.condition(:process_exits) + # + # Trigger if process exits: + # + # on.condition(:process_exits) do |c| + # c.pid_file = "/var/run/mongrel.3000.pid" + # end class ProcessExits < EventCondition def initialize self.info = "process exited" diff --git a/lib/god/conditions/process_running.rb b/lib/god/conditions/process_running.rb index e45a1b5..d500df0 100644 --- a/lib/god/conditions/process_running.rb +++ b/lib/god/conditions/process_running.rb @@ -1,6 +1,38 @@ module God module Conditions + # Condition Symbol :process_running + # Type: Poll + # + # Trigger when a process is running or not running depending on attributes. + # + # Paramaters + # Required + # +pid_file+ is the pid file of the process in question. Automatically + # populated for Watches. + # +running" specifies whether you want to trigger if the process is + # running (true) or whether it is not running (false) + # + # Examples + # + # Trigger if process IS NOT running (from a Watch): + # + # on.condition(:process_running) do |c| + # c.running = false + # end + # + # Trigger if process IS running (from a Watch): + # + # on.condition(:process_running) do |c| + # c.running = true + # end + # + # Non-Watch Tasks must specify a PID file: + # + # on.condition(:process_running) do |c| + # c.running = false + # c.pid_file = "/var/run/mongrel.3000.pid" + # end class ProcessRunning < PollCondition attr_accessor :running -- 2.11.4.GIT