Class: Inspec::Resources::LinuxFileSystemResource

Inherits:
FsManagement
  • Object
show all
Defined in:
lib/resources/filesystem.rb

Instance Attribute Summary

Attributes inherited from FsManagement

#inspec

Instance Method Summary collapse

Methods inherited from FsManagement

#initialize

Constructor Details

This class inherits a constructor from Inspec::Resources::FsManagement

Instance Method Details

#info(partition) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/resources/filesystem.rb', line 94

def info(partition)
  cmd = inspec.command("df #{partition} -T")
  raise Inspec::Exceptions::ResourceFailed, "Unable to get available space for partition #{partition}" if cmd.stdout.nil? || cmd.stdout.empty? || !cmd.exit_status.zero?
  value = cmd.stdout.split(/\n/)[1].strip.split(' ')
  {
    name: partition,
    size_kb: value[2].to_i,
    free_kb: value[4].to_i,
    type: value[1].to_s,
  }
end