sensu-plugins / sensu-plugins-raid-checks

Sensu RAID array checks
http://sensu-plugins.io
MIT License
1 stars 21 forks source link

Problem with software raid #19

Closed ushacow closed 6 years ago

ushacow commented 6 years ago

Hi! I suppose there is a mistake in software raid check. I have software raid, but check-raid.rb ignores it and print "CheckRaid OK: No RAID present". Here is /proc/mdstat:

Personalities : [raid1] 
md0 : active raid1 sda2[0] sdb2[1]
      3906691072 blocks super 1.2 [2/2] [UU]
      bitmap: 2/30 pages [8KB], 65536KB chunk

unused devices: <none>

I think mistake is in return unless mg.empty? (it should be return if mg.empty?) Sorry for this issue, I may be wrong, I don't have an experience with Ruby

simseb commented 6 years ago

Same here... something like: return unless !mg.empty?

mtdavidson commented 6 years ago

Glad this is not just me agreed makes more sense that it should return if the mg is empty. But same I'm no ruby expert.

corro commented 6 years ago

I can confirm that software raid checks currently don't work. Downgrading to sensu-plugins-raid-checks 2.0.0 fixes the issue. It seems like commit d7f53f6828127791ae2e215a1f316f1bd66766c0 is to blame, it inverted the check for mg.empty?. The following patch should fix that:

--- check-raid.rb.old   2018-04-03 15:33:36.588418165 +0200
+++ check-raid.rb.new   2018-04-03 15:33:44.308418606 +0200
@@ -44,7 +44,7 @@
     return unless File.exist?('/proc/mdstat')
     contents = File.read('/proc/mdstat')
     mg = contents.lines.grep(/active|blocks/)
-    return unless mg.empty?
+    return if mg.empty?
     sg = mg.to_s.lines.grep(/\]\(F\)|[\[U]_/)
     if sg.empty?
       ok 'Software RAID OK'
majormoses commented 6 years ago

released: https://rubygems.org/gems/sensu-plugins-raid-checks/versions/2.0.2

closed via #20