I have written some useful script to monitor HDD on HP server via hpacucli and send email notification
To find amount of disks, run
Then count them
[root@hp-proliant]# cat /usr/local/sbin/hpacucli_mon
#!/bin/bash
# Usage:
# hpacucli_mon <NUM OF ARRAYS> <NUM OF PHISYCAL DISKS> <MAIL TO>
HP_SLOT=`/usr/sbin/hpacucli ctrl all show status | grep -o -P 'Slot.{0,2}'| awk -F" " '{print $2}'`
if [ "$3" = "" ] || [ "$4" != "" ];then
echo ""
echo "ERROR: hpacucli_mon requires number of arrays, disks and valid email"
echo ""
echo "Usage: hpacucli_mon <NUM OF ARRAYS> <NUM OF PHISYCAL DISKS> <MAIL TO>"
echo ""
echo "To find amount of arrays and disks you do have run:"
echo "/usr/sbin/hpacucli ctrl slot=$HP_SLOT ld all show status"
echo "and"
echo "/usr/sbin/hpacucli ctrl slot=$HP_SLOT pd all show status"
exit
fi
EMAILMESSAGE="/tmp/hpacucli_message.txt"
LOCAL_IP=`/sbin/ifconfig eth0 | grep -Eo '(([0-9]{1,3}\.){3}[0-9]{1,3})' | grep -v ".255"`
MSG_SUBJECT="Smart HP array failure at $LOCAL_IP"
OK_ARRAY_CNT=`/usr/sbin/hpacucli ctrl slot=$HP_SLOT ld all show status | grep -o "OK" | wc -l`
OK_DISKS_CNT=`/usr/sbin/hpacucli ctrl slot=$HP_SLOT pd all show status | grep -o "OK" | wc -l`
if [ "$OK_ARRAY_CNT" -ne $1 ] || [ "$OK_DISKS_CNT" -ne $2 ]; then
echo "We have encountered a problem at $LOCAL_IP" > $EMAILMESSAGE
echo "Take look at this: " >> $EMAILMESSAGE
/usr/sbin/hpacucli ctrl slot=$HP_SLOT ld all show status >> $EMAILMESSAGE
/usr/sbin/hpacucli ctrl slot=$HP_SLOT pd all show status >> $EMAILMESSAGE
echo "===============================================" >> $EMAILMESSAGE
echo "INFORMATION PROVIDED BY SMARTCTL:" >> $EMAILMESSAGE
echo "" >> $EMAILMESSAGE
for (( i=0; i<$2; i++ ))
do
/usr/sbin/smartctl -a -d cciss,$i /dev/cciss/c0d0 | grep -E '(Serial|Health)' >> $EMAILMESSAGE
echo "" >> $EMAILMESSAGE
done
mail -s "$MSG_SUBJECT" "$3" < $EMAILMESSAGE
fi
To use this, just add to crontab:
00 */1 * * * /usr/local/sbin/hpacucli_mon <NUM OF LOGICAL HDD> <NUM OF PHYSICAL HDD> <YOUR@EMAIL>
To find amount of disks, run
export HP_SLOT=$(/usr/sbin/hpacucli ctrl all show status | grep -o -P 'Slot.{0,2}'| awk -F" " '{print $2}') && /usr/sbin/hpacucli ctrl slot=$HP_SLOT ld all show status && /usr/sbin/hpacucli ctrl slot=$HP_SLOT pd all show status
Then count them
No comments:
Post a Comment