This is a simple Nagios plugin to monitor the state of RAID arrays on 3ware/LSI RAID cards, using 3ware's tw_cli utility, which you can download from the 3ware/LSI site (see below).
The plugin automatically determines which 3ware/LSI RAID controller cards are present, and which RAID arrays are configured, and checks the status of each.
This means it can happily support monitoring of multiple controller cards and RAID arrays, and does not need to be told which card number / unit number to monitor - it will just Do The Right Thing.
Besides the obvious (Nagios/NRPE, Perl, and and the Monitoring::Plugin module from CPAN), you'll also need 3ware's tw_cli utility.
You can download tw_cli from the 3ware (now LSI) website, for instance:
http://www.lsi.com/channel/products/raid_controllers/sata_sas/3ware_9690sa4i/index.html
As that URL didn't work for me, at least with Javascript disabled, I've also mirrored the files for easy download:
Linux (32 bit): http://www.preshweb.co.uk/downloads/tw_cli-linux-x86-9.5.3.tgz
Linux (64 bit): http://www.preshweb.co.uk/downloads/tw_cli-linux-x86_64-9.5.3.tgz
It appears to be compatible with most cards, so you don't have to pick the specific card you have from the list.
Extract the tarball, and you'll find the tw_cli util and man pages. Make tw_cli executable (chmod +x tw_cli) then move it to /usr/local/sbin/.
You probably don't want to be running your Nagios plugins as root. However, tw_cli needs to run as root. So, this script uses sudo to execute tw_cli as root.
You'll need to allow this to happen with no password. For security, I'd only allow the nagios user to run the tw_cli command - add something like this to the sudoers file:
nagios ALL= NOPASSWD: /usr/local/sbin/tw_cliBy default, this plugin expects to find the tw_cli binary in your $PATH. If you can run sudo tw_cli yourself and get output, it should work. However, if you need to, you can provide the path to the tw_cli binary using the --tw_cli option, e.g.:
./nagios-3ware-raid-check --tw_cli=/path/to/tw_cliThis may be a good idea anyway, to ensure that the binary that the plugin executes (as root, remember!) is the one you expect, and not some other binary/script named tw_cli which appeared in some other directory earlier in your $PATH.
This plugin is developed on GitHub at:
https://github.com/bigpresh/misc-scripts/tree/master/nagios_3ware_raid_check
Patches / bug reports / feedback welcome.
David Precious <[email protected]>