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.



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

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

Instance Attribute Details

#aboveObject

Returns the value of attribute above.



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

def above
  @above
end

#mount_pointObject

Returns the value of attribute mount_point.



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

def mount_point
  @mount_point
end

Instance Method Details

#testObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/god/conditions/disk_usage.rb', line 21

def test
  self.info = []
  usage = `df -P | grep -i " #{mount_point}$" | awk '{print $5}' | sed 's/%//'`
  if usage.to_i > above
    self.info = 'disk space out of bounds'
    true
  else
    false
  end
end

#valid?Boolean

Returns:

  • (Boolean)


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

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