bin/metrics-disk-usage.rb in sensu-plugins-disk-checks-5.0.1 vs bin/metrics-disk-usage.rb in sensu-plugins-disk-checks-5.1.0

- old
+ new

@@ -1,6 +1,8 @@ #! /usr/bin/env ruby +# frozen_string_literal: true + # # disk-usage-metrics # # DESCRIPTION: # This plugin uses df to collect disk capacity metrics @@ -103,11 +105,12 @@ `#{command}`.split("\n").drop(1).each do |line| _, _, used, avail, used_p, mnt = line.split unless %r{/sys[/|$]|/dev[/|$]|/run[/|$]} =~ mnt - next if config[:ignore_mnt] && config[:ignore_mnt].find { |x| mnt.match(x) } + next if config[:ignore_mnt]&.find { |x| mnt.match(x) } next if config[:include_mnt] && !config[:include_mnt].find { |x| mnt.match(x) } + mnt = if config[:flatten] mnt.eql?('/') ? 'root' : mnt.gsub(/^\//, '') else # If mnt is only / replace that with root if its /tmp/foo # replace first occurance of / with root.