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
24
25
26
27
28
29
# File 'lib/god/conditions/disk_usage.rb', line 20

def test
  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

#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