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

Fix for #78 check-smart.rb ignoring 'override' #79

Closed sovaa closed 7 years ago

sovaa commented 7 years ago

Pull Request Checklist

Is this in reference to an existing issue?

General

New Plugins

Purpose

Known Compatibility Issues

sovaa commented 7 years ago

With fix:

[root@host ~]# grep -nA14 "def check_smart_capability" check-smart.rb 
79:  def check_smart_capability!
80-    output = `sudo #{@smart_binary} -i #{device_path}`
81-    @smart_available = !output.scan(/SMART support is:\s+Available/).empty?
82-    @smart_enabled = !output.scan(/SMART support is:\s+Enabled/).empty?
83-    @capability_output = output
84-  end
85-
86-  # Check the SMART health
87-  #
88-  def check_health!
89-    output = `sudo #{@smart_binary} -H #{device_path}`
90-    @smart_healthy = !output.scan(/PASSED|OK$/).empty?
91-    @health_output = output
92-  end
93-end
[root@host ~]# grep override smart.json 
      { "path": "sda", "override": "/dev/sda -d sat+megaraid,0" }
[root@host ~]# /opt/sensu/embedded/bin/ruby ./check-smart.rb -j smart.json
CheckSMART OK: PASSED

Without fix:

[root@host ~]# grep -nA14 "def check_smart_capability" check-smart.rb 
79:  def check_smart_capability!
80-    output = `sudo #{@smart_binary} -i #{@device_path}`
81-    @smart_available = !output.scan(/SMART support is:\s+Available/).empty?
82-    @smart_enabled = !output.scan(/SMART support is:\s+Enabled/).empty?
83-    @capability_output = output
84-  end
85-
86-  # Check the SMART health
87-  #
88-  def check_health!
89-    output = `sudo #{@smart_binary} -H #{@device_path}`
90-    @smart_healthy = !output.scan(/PASSED|OK$/).empty?
91-    @health_output = output
92-  end
93-end
[root@host ~]# grep override smart.json
      { "path": "sda", "override": "/dev/sda -d sat+megaraid,0" }
[root@host ~]# /opt/sensu/embedded/bin/ruby ./check-smart.rb -j smart.json
CheckSMART UNKNOWN: smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-514.6.2.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

Smartctl open device: /dev/sda failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'
majormoses commented 7 years ago

released: https://rubygems.org/gems/sensu-plugins-disk-checks/versions/2.4.1