Class: God::Conditions::DiskUsage

Inherits:
PollCondition show all
Defined in:
lib/god/conditions/disk_usage.rb

Instance Attribute Summary collapse

Attributes inherited from PollCondition

#interval

Attributes inherited from God::Condition

#info, #notify, #phase, #transition

Attributes inherited from Behavior

#watch

Instance Method Summary collapse

Methods inherited from PollCondition

#after, #before

Methods inherited from God::Condition

#friendly_name, generate, valid?

Methods inherited from Behavior

#after_restart, #after_start, #after_stop, #before_restart, #before_start, #before_stop, #friendly_name, generate

Methods included from God::Configurable

#base_name, complain, #complain, #friendly_name, #prepare, #reset

Constructor Details

#initializeDiskUsage

Returns a new instance of DiskUsage.



7
8
9
10
11
# File 'lib/god/conditions/disk_usage.rb', line 7

def initialize
  super
  self.above = nil
  self.mount_point = nil
end

Instance Attribute Details

#aboveObject

Returns the value of attribute above.



5
6
7
# File 'lib/god/conditions/disk_usage.rb', line 5

def above
  @above
end

#mount_pointObject

Returns the value of attribute mount_point.



5
6
7
# File 'lib/god/conditions/disk_usage.rb', line 5

def mount_point
  @mount_point
end

Instance Method Details

#testObject



20
21
22
23
# File 'lib/god/conditions/disk_usage.rb', line 20

def test
  usage = `df | grep -i " #{self.mount_point}$" | awk '{print $5}' | sed 's/%//'`
  usage.to_i > self.above
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
# File 'lib/god/conditions/disk_usage.rb', line 13

def valid?
  valid = true
  valid &= complain("Attribute 'mount_point' must be specified", self) if self.mount_point.nil?
  valid &= complain("Attribute 'above' must be specified", self) if self.above.nil?
  valid
end