OVH Community, your new community space.

script check hardware raid


ab-tech.it
19-06-2015, 22:42
Hi,
i have a server with raid hardware.
I want to check disk/raid status, so that if there is a problem send an alert (email)
in that case i can move VM on other server and boot in rescue mode, open ticket, ecc...
On server runs proxmox (official ovh distro)

Reading OVH guide, i founf this command
# MegaCli -AdpAllInfo -aALL
and works because i see "raid status OK"
so i think to do this script e "cron" it every hour

Code:
#!/bin/bash
cd /root/
MegaCli -AdpAllInfo -aALL | grep "Degraded" > degraded.txt
MegaCli -AdpAllInfo -aALL | grep "Failed" >> degraded.txt
cat degraded.txt | grep "1" > /dev/null
if [[ $? -eq 0 ]];
then
cat degraded.txt | mailx -s 'Degraded RAID on '$HOSTNAME myemail@email.com
fi
in this case i receive an email when script find a word Degraded or Failed

i configured also smartools for a more security...
If you this script is correct? or is possibile improve it?

thank you in advance