Here's a quick hack to add basic RAID checking with email alerts into your HP Server on Centos 7. This will allow you to receive email alerts when your RAID status is not OK. We're assuming you already installed Centos using the official HP RAID driver and are using your inbuilt HP RAID controller. We also assume your system is able to send emails using the mail command. This is tested and working on HP Microserver Gen8 and HP DL80 Gen9 but should work for any HP server which supports hpssacli.
wget http://downloads.linux.hpe.com/SDR/repo/mcp/centos/7/x86_64/current/hpss...
yum install mailx hpssacli*
vim /opt/checkRaid.pl
and paste the below code, then save. In our example we expect 5 lines containing "OK". Your RAID could be different so use "hpssacli ctrl all show config" to to find out how many lines containing the work "OK" are normal for your setup then adjust the number in the code below accordingly.
#!/usr/bin/perl
my $result=`hpssacli ctrl all show config`;
if(`echo "$result"|grep OK|wc -l`!=5){
`echo "$result" | mail -s 'Bedale RAID Failure' youremail\@here.com`;}
chmod +x /opt/checkRaid.pl
crontab -e
*/30 * * * * /opt/checkRaid.pl
Done! Your server will now email you when your RAID status is not OK.As you can see above, the cron check happens every 30 mins but you can adjust it to suit. There is plenty of potential to make this more clever, but it's a good starting point. Next we'll show you how to use this within a nagios/icinga environment.