Sha256: d4329789739b9209f024274d54688ce926ef4cea689b27945b0dd745e6bf0bc4

Contents?: true

Size: 778 Bytes

Versions: 10

Compression:

Stored size: 778 Bytes

Contents

module God
  module Conditions

    class DiskUsage < PollCondition
      attr_accessor :above, :mount_point

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

      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

      def test
        self.info = []
        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
          return false
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
resurrected_god-0.14.0 lib/god/conditions/disk_usage.rb
mcproc-2016.2.20 lib/god/conditions/disk_usage.rb
god-0.13.7 lib/god/conditions/disk_usage.rb
god-0.13.6 lib/god/conditions/disk_usage.rb
god-0.13.5 lib/god/conditions/disk_usage.rb
god-0.13.4 lib/god/conditions/disk_usage.rb
god-0.13.3 lib/god/conditions/disk_usage.rb
god-0.13.2 lib/god/conditions/disk_usage.rb
god-0.13.1 lib/god/conditions/disk_usage.rb
god-0.13.0 lib/god/conditions/disk_usage.rb