bin/check-raid.rb in sensu-plugins-raid-checks-1.0.0 vs bin/check-raid.rb in sensu-plugins-raid-checks-2.0.0
- old
+ new
@@ -28,10 +28,16 @@
#
# Check Raid
#
class CheckRaid < Sensu::Plugin::Check::CLI
+ option :log,
+ description: 'Enables or disables logging for megacli',
+ short: '-l VALUE',
+ long: '--log VALUE',
+ boolean: true,
+ default: false
# Check software raid
#
def check_software
if File.exist?('/proc/mdstat')
contents = File.read('/proc/mdstat')
@@ -101,10 +107,14 @@
# Check Megaraid
#
def check_mega_raid
if File.exist?('/usr/sbin/megacli')
- contents = `/usr/sbin/megacli -AdpAllInfo -aALL`
+ contents = if config[:log]
+ `/usr/sbin/megacli -AdpAllInfo -aALL`
+ else
+ `/usr/sbin/megacli -AdpAllInfo -aALL -NoLog`
+ end
failed = contents.lines.grep(/(Critical|Failed) Disks\s+\: 0/)
degraded = contents.lines.grep(/Degraded\s+\: 0/)
# #YELLOW
unless failed.empty? || degraded.empty? # rubocop:disable UnlessElse
ok 'MegaRaid RAID OK'