Sha256: a6fce7bd4a7ba6405cfbff680a77d0c411a2a1d046640d4095eebf7bc72f5c3b

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 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
        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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
god-0.12.1 lib/god/conditions/disk_usage.rb
god-0.12.0 lib/god/conditions/disk_usage.rb