bin/metrics-disk-capacity.rb in sensu-plugins-disk-checks-1.1.3 vs bin/metrics-disk-capacity.rb in sensu-plugins-disk-checks-2.0.0

- old
+ new

@@ -37,11 +37,11 @@ # class DiskCapacity < Sensu::Plugin::Metric::CLI::Graphite option :scheme, description: 'Metric naming scheme, text to prepend to .$parent.$child', long: '--scheme SCHEME', - default: "#{Socket.gethostname}" + default: Socket.gethostname.to_s # Unused ? # def convert_integers(values) values.each_with_index do |value, index| @@ -61,17 +61,17 @@ `df -PT`.split("\n").drop(1).each do |line| begin fs, _type, _blocks, used, avail, capacity, _mnt = line.split timestamp = Time.now.to_i - if fs.match('/dev') + if fs =~ '/dev' fs = fs.gsub('/dev/', '') metrics = { disk: { "#{fs}.used" => used, "#{fs}.avail" => avail, - "#{fs}.capacity" => capacity.gsub('%', '') + "#{fs}.capacity" => capacity.delete('%') } } metrics.each do |parent, children| children.each do |child, value| output [config[:scheme], parent, child].join('.'), value, timestamp @@ -87,16 +87,16 @@ `df -Pi`.split("\n").drop(1).each do |line| begin fs, _inodes, used, avail, capacity, _mnt = line.split timestamp = Time.now.to_i - if fs.match('/dev') + if fs =~ '/dev' fs = fs.gsub('/dev/', '') metrics = { disk: { "#{fs}.iused" => used, "#{fs}.iavail" => avail, - "#{fs}.icapacity" => capacity.gsub('%', '') + "#{fs}.icapacity" => capacity.delete('%') } } metrics.each do |parent, children| children.each do |child, value| output [config[:scheme], parent, child].join('.'), value, timestamp