Module: Facter::Util::Resolvers::FilesystemHelper
- Included in:
- Resolvers::Macosx::Mountpoints, Resolvers::Mountpoints, Resolvers::Solaris::Mountpoints
- Defined in:
- lib/facter/util/resolvers/filesystem_helper.rb
Overview
Constant Summary collapse
- MOUNT_KEYS =
%i[device filesystem path options available available_bytes size size_bytes used used_bytes capacity].freeze
Class Method Summary collapse
- .compute_capacity(used, total) ⇒ Object
- .read_mountpoint_stats(path) ⇒ Object
- .read_mountpoints ⇒ Object
Class Method Details
.compute_capacity(used, total) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 21 def compute_capacity(used, total) if used == total '100%' elsif used.positive? "#{format('%<value>.2f', value: (used / total.to_f * 100))}%" else '0%' end end |
.read_mountpoint_stats(path) ⇒ Object
16 17 18 19 |
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 16 def read_mountpoint_stats(path) require 'sys/filesystem' Sys::Filesystem.stat(path) end |
.read_mountpoints ⇒ Object
11 12 13 14 |
# File 'lib/facter/util/resolvers/filesystem_helper.rb', line 11 def read_mountpoints require 'sys/filesystem' force_utf(Sys::Filesystem.mounts) end |