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.
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
#above ⇒ Object
Returns the value of attribute above.
5 6 7 |
# File 'lib/god/conditions/disk_usage.rb', line 5 def above @above end |
#mount_point ⇒ Object
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
#test ⇒ Object
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
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 |