sensu-plugins / sensu-plugins-disk-checks

This plugin provides native disk instrumentation for monitoring and metrics collection, including: health, usage, and various metrics.
http://sensu-plugins.io
MIT License
27 stars 63 forks source link

check-smart.rb doesn't use attribute accessor thus ignoring 'override' #78

Closed sovaa closed 7 years ago

sovaa commented 7 years ago
  # Check for SMART cspability
  #
  def check_smart_capability!
    output = `sudo #{@smart_binary} -i #{@device_path}`
    @smart_available = !output.scan(/SMART support is:\s+Available/).empty?
    @smart_enabled = !output.scan(/SMART support is:\s+Enabled/).empty?
    @capability_output = output
  end

  # Check the SMART health
  #
  def check_health!
    output = `sudo #{@smart_binary} -H #{@device_path}`
    @smart_healthy = !output.scan(/PASSED|OK$/).empty?
    @health_output = output
  end

Both check_health and check_smart_capability accesses device_path directly instead of the accessor:

  def device_path
    if @override_path.nil?
      @device_path
    else
      @override_path
    end
  end

This causes the override_path to be ignored for those two checks, resulting in the following output:

# /opt/sensu/embedded/bin/ruby //opt/sensu/embedded/bin/check-smart.rb -j /etc/sensu/conf.d/smart.json 
CheckSMART UNKNOWN: No SMART capable devices found