glensc / nagios-plugin-check_raid

Nagios/Icinga/Sensu plugin to check current server's RAID status ⛺
144 stars 84 forks source link

Fixing hpacucli to respect the cache_fail and bbulearn command options #193

Closed phsm closed 5 years ago

phsm commented 5 years ago

Hello, A small fix to make the program respect the --cache-fail and --bbulearn settings.

Debug output:

# ./check_raid '-p' 'mdstat,megacli,mpt,megaraid,tw_cli,cciss,sas2ircu,smartctl,hpssacli' '--cache-fail' 'OK' --bbulearn OK -d
check_raid 4.0.9
Visit <https://github.com/glensc/nagios-plugin-check_raid#reporting-bugs> how to report bugs
Please include output of **ALL** commands in bugreport

DEBUG EXEC: /proc/mdstat at ./check_raid line 503.
DEBUG EXEC: /usr/sbin/hpssacli controller all show status at ./check_raid line 503.
DEBUG EXEC: /usr/sbin/hpssacli controller slot=0 logicaldrive all show at ./check_raid line 503.
OK: hpssacli:[Smart Array P420i[OK, Cache: Temporarily Disabled, Battery: Recharging]: Array A(OK)[LUN1:OK]]
# cat /proc/mdstat
Personalities : 
unused devices: <none>
# /usr/sbin/hpssacli controller all show status

Smart Array P420i in Slot 0 (Embedded)
   Controller Status: OK
   Cache Status: Temporarily Disabled
   Battery/Capacitor Status: Recharging
# /usr/sbin/hpssacli controller slot=0 logicaldrive all show

Smart Array P420i in Slot 0 (Embedded)

   array A

      logicaldrive 1 (279.4 GB, RAID 1, OK)
glensc commented 5 years ago

can you add new testcase based on your setup?

phsm commented 5 years ago

Hello, added a test case prototype, but it fails due to status code. Seems that the options aren't passed to the test. Can you help me with figuring out how to properly pass them? (sorry, I've never made tests in Perl)

phsm commented 5 years ago

I do not understand. On my machine tests are passing:

~/git/nagios-plugin-check_raid $ make test
perl -MTest::Harness -e 'runtests @ARGV' t/*.t
t/check_aaccli.t .... ok   
t/check_afacli.t .... ok   
t/check_arcconf.t ... ok       
t/check_areca.t ..... ok     
t/check_cciss.t ..... ok     
t/check_cmdtool2.t .. ok   
t/check_dmraid.t .... ok     
t/check_dm.t ........ ok     
t/check_dpt_i2o.t ... ok   
t/check_gdth.t ...... ok     
t/check_hpacucli.t .. ok     
t/check_hp_msa.t .... ok   
t/check_ips.t ....... ok   
t/check_lsraid.t .... ok   
t/check_lsscsi.t .... ok   
t/check_lsvg.t ...... ok   
t/check_mdstat.t .... ok       
t/check_megacli.t ... ok       
t/check_megarc.t .... ok   
t/check_metastat.t .. ok     
t/check_mpt.t ....... ok     
t/check_mvcli.t ..... ok     
t/check_sas2ircu.t .. ok     
t/check_smartctl.t .. ok   
t/check_tw_cli.t .... ok     
t/enabled.t ......... ok     
t/status.t .......... ok     
t/sudo.t ............ ok     
All tests successful.
Files=28, Tests=999,  2 wallclock secs ( 0.12 usr  0.03 sys +  2.08 cusr  0.26 csys =  2.49 CPU)
Result: PASS

But travis says they aren't

phsm commented 5 years ago

Fixed tests (didn't know that the dump should be also committed), now the build passes

glensc commented 5 years ago

good work. thanks!