Class: God::Conditions::DiskUsage
- Inherits:
-
PollCondition
- Object
- Behavior
- God::Condition
- PollCondition
- God::Conditions::DiskUsage
- Defined in:
- lib/god/conditions/disk_usage.rb
Instance Attribute Summary collapse
-
#above ⇒ Object
Returns the value of attribute above.
-
#mount_point ⇒ Object
Returns the value of attribute mount_point.
Attributes inherited from PollCondition
Attributes inherited from God::Condition
#info, #notify, #phase, #transition
Attributes inherited from Behavior
Instance Method Summary collapse
-
#initialize ⇒ DiskUsage
constructor
A new instance of DiskUsage.
- #test ⇒ Object
- #valid? ⇒ Boolean
Methods inherited from PollCondition
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
#initialize ⇒ DiskUsage
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
#above ⇒ Object
Returns the value of attribute above.
6 7 8 |
# File 'lib/god/conditions/disk_usage.rb', line 6 def above @above end |
#mount_point ⇒ Object
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
#test ⇒ Object
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
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 |