bin/check-fstab-mounts.rb in sensu-plugins-disk-checks-5.0.1 vs bin/check-fstab-mounts.rb in sensu-plugins-disk-checks-5.1.0
- old
+ new
@@ -1,6 +1,8 @@
#! /usr/bin/env ruby
+# frozen_string_literal: true
+
#
# check-fstab-mounts
#
# DESCRIPTION:
# Check /etc/mtab to ensure all filesystems of the requested type(s) from
@@ -49,41 +51,42 @@
@mtab = IO.readlines '/etc/mtab'
@swap_mounts = IO.readlines '/proc/swaps'
@missing_mounts = []
end
- def resolve_device(d)
- if d.start_with?('UUID=')
- uuid = d.split('=')[1]
+ def resolve_device(dev)
+ if dev.start_with?('UUID=')
+ uuid = dev.split('=')[1]
path = File.join('/', 'dev', 'disk', 'by-uuid', uuid)
if File.exist?(path) && File.symlink?(path)
return File.realpath(path)
end
end
- if d.start_with?('LABEL=')
- label = d.split('=')[1]
+ if dev.start_with?('LABEL=')
+ label = dev.split('=')[1]
path = File.join('/', 'dev', 'disk', 'by-label', label)
if File.exist?(path) && File.symlink?(path)
return File.realpath(path)
end
end
- if d.start_with?('/dev/mapper')
- if File.symlink?(d)
- d = File.realpath(d, '/')
+ if dev.start_with?('/dev/mapper')
+ if File.symlink?(dev)
+ dev = File.realpath(dev, '/')
end
end
- d
+ dev
end
# Check by mount destination (col 2 in fstab and proc/mounts)
#
def check_mounts
@fstab.each do |line|
next if line =~ /^\s*#/
next if line =~ /^\s*$/
+
fields = line.split(/\s+/)
next if fields[1] == 'none' || (fields[3].include? 'noauto')
next if config[:fstypes] && !config[:fstypes].include?(fields[2])
if fields[2] != 'swap'