Sha256: 756dfa0f99898b5f0c4f75d84872d2b2ac4b2d76d0feae22b8f6bca5f54f07ad

Contents?: true

Size: 672 Bytes

Versions: 12

Compression:

Stored size: 672 Bytes

Contents

# frozen_string_literal: true

module Facter
  module FilesystemHelper
    MOUNT_KEYS = %i[device filesystem path options
                    available available_bytes size
                    size_bytes used used_bytes capacity].freeze

    def self.read_mountpoints
      require 'sys/filesystem'
      Sys::Filesystem.mounts
    end

    def self.read_mountpoint_stats(path)
      require 'sys/filesystem'
      Sys::Filesystem.stat(path)
    end

    def self.compute_capacity(used, total)
      if used == total
        '100%'
      elsif used.positive?
        "#{format('%.2f', 100.0 * used.to_f / total.to_f)}%"
      else
        '0%'
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
facter-4.0.18 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.17 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.16 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.15 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.14 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.13 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.12 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.11 lib/resolvers/utils/filesystem_helper.rb
facter-4.0.10.pre lib/resolvers/utils/filesystem_helper.rb
facter-4.0.9.pre lib/resolvers/utils/filesystem_helper.rb
facter-4.0.8.pre lib/resolvers/utils/filesystem_helper.rb
facter-4.0.7.pre lib/resolvers/utils/filesystem_helper.rb