class ForemanMaintain::Utils::Disk::Device

Constants

EXTERNAL_MOUNT_TYPE

Attributes

dir[RW]
io_device[R]
name[RW]
read_speed[RW]
unit[RW]

Public Class Methods

new(dir) click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 17
def initialize(dir)
  @dir = dir
  @name = find_device
  logger.info "#{dir} is externally mounted" if externally_mounted?
  @io_device = IODevice.new(dir)
end

Public Instance Methods

performance() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 30
def performance
  "#{read_speed} #{unit}"
end
slow_disk_error_msg() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 24
def slow_disk_error_msg
  "Slow disk detected #{dir} mounted on #{name}.
     Actual disk speed: #{read_speed} #{default_unit}
     Expected disk speed: #{expected_io} #{default_unit}."
end

Private Instance Methods

default_unit() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 45
def default_unit
  Checks::Disk::Performance::DEFAULT_UNIT
end
expected_io() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 49
def expected_io
  Checks::Disk::Performance::EXPECTED_IO
end
externally_mounted?() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 36
def externally_mounted?
  device_type = execute("stat -f -c %T #{dir}")
  EXTERNAL_MOUNT_TYPE.include?(device_type)
end
find_device() click to toggle source
# File lib/foreman_maintain/utils/disk/device.rb, line 41
def find_device
  execute("df -h #{dir} | sed -n '2p' | awk '{print $1}'")
end