Sha256: 242ceb2caa0d77b929f64676889697d89f095cbe050d6a2fbd71ad10004ee68f

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

#! /usr/bin/env ruby
#
#   check-disk-fail
#
# DESCRIPTION:
#   Check for failing disks
#   Greps through dmesg output looking for indications that a drive is failing.
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#
# USAGE:
#
# NOTES:
#
# LICENSE:
#   Coppyright 07/14/2014 Shane Feek and  Alan Smith.
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'

#
# Check Disk Fail
#
class CheckDiskFail < Sensu::Plugin::Check::CLI
  # Main function
  #
  # Check the contents of dmesg for a set of given strings
  def run
    dmesg = `dmesg`.lines

    %w(Read Write Smart).each do |v|
      found = dmesg.grep(/failed command\: #{v.upcase}/)
      # #YELLOW
      unless found.empty?  # rubocop:disable IfUnlessModifier
        critical "Disk #{v} Failure"
      end
    end
    ok
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sensu-plugins-disk-checks-0.0.1.alpha.4 bin/check-disk-fail.rb
sensu-plugins-disk-checks-0.0.1.alpha.2 bin/check-disk-fail.rb