diff options
Diffstat (limited to 'lib/ohai/plugins/filesystem.rb')
-rw-r--r-- | lib/ohai/plugins/filesystem.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/ohai/plugins/filesystem.rb b/lib/ohai/plugins/filesystem.rb index e86d0908..f6cb6a2b 100644 --- a/lib/ohai/plugins/filesystem.rb +++ b/lib/ohai/plugins/filesystem.rb @@ -271,6 +271,30 @@ Ohai.plugin(:Filesystem) do fs end + def collect_btrfs_data(entry) + btrfs = Mash.new + if entry[:fs_type] == "btrfs" && entry["uuid"] + uuid = entry["uuid"] + alloc = "/sys/fs/btrfs/#{uuid}/allocation" + %w{data metadata system}.each do |bg_type| + dir = "#{alloc}/#{bg_type}" + %w{single dup}.each do |raid| + if file_exist?("#{dir}/#{raid}") + btrfs["raid"] = raid + end + end + logger.trace("Plugin Filesystem: reading btrfs allocation files at #{dir}") + btrfs["allocation"] ||= Mash.new + btrfs["allocation"][bg_type] ||= Mash.new + %w{total_bytes bytes_used}.each do |field| + bytes = file_read("#{dir}/#{field}").chomp.to_i + btrfs["allocation"][bg_type][field] = "#{bytes}" + end + end + end + btrfs + end + collect_data(:linux) do fs = Mash.new @@ -394,6 +418,12 @@ Ohai.plugin(:Filesystem) do end end + fs.each do |key, entry| + if entry[:fs_type] == "btrfs" + fs[key][:btrfs] = collect_btrfs_data(entry) + end + end + by_pair = fs by_device = generate_device_view(fs) by_mountpoint = generate_mountpoint_view(fs) |