Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../proc/self/root/opt/maint/bin
File: bbu_relearn.sh
#!/bin/bash
[0] Fix | Delete
# Do a relearn when BBU charge falls low
[1] Fix | Delete
# Vanessa V 6/7/12
[2] Fix | Delete
[3] Fix | Delete
[4] Fix | Delete
# Define variables
[5] Fix | Delete
[6] Fix | Delete
ARCH=$(uname -p)
[7] Fix | Delete
if [ "$ARCH" == "x86_64" ]; then
[8] Fix | Delete
MEGAPATH="/opt/MegaRAID/MegaCli/MegaCli64"
[9] Fix | Delete
else
[10] Fix | Delete
MEGAPATH="/opt/MegaRAID/MegaCli/MegaCli"
[11] Fix | Delete
fi
[12] Fix | Delete
[13] Fix | Delete
# If we already have something in progress, don't do anything
[14] Fix | Delete
[15] Fix | Delete
STATUS=$($MEGAPATH -AdpBbuCmd -GetBbuStatus -aALL | grep "Charger Status")
[16] Fix | Delete
[17] Fix | Delete
if echo "$STATUS" | grep -q -i "In Progress"; then
[18] Fix | Delete
echo "Relearn already in progress... exiting"
[19] Fix | Delete
exit 0
[20] Fix | Delete
else
[21] Fix | Delete
[22] Fix | Delete
# If we already have a progress file, remove it (because we're not in progress anymore)
[23] Fix | Delete
[ -f /home/nagios/bbu_relearn.progress ] && rm -f /home/nagios/bbu_relearn.progress
[24] Fix | Delete
[ -f /home/nagios/bbu_relearn.error ] && rm -f /home/nagios/bbu_relearn.error
[25] Fix | Delete
[26] Fix | Delete
# See if our BBU is undercharged
[27] Fix | Delete
[28] Fix | Delete
if [ -f $MEGAPATH ]; then
[29] Fix | Delete
[30] Fix | Delete
BBU_OK=$(sudo $MEGAPATH AdpBbuCmd -GetBbuStatus -aALL | grep '^isSOHGood' |awk '{print $2}')
[31] Fix | Delete
if [ "$BBU_OK" == "Yes" ]; then
[32] Fix | Delete
# BBU_OK=$($MEGAPATH -AdpBbuCmd -GetBbuStatus -aALL | awk '$0~/Relative State of Charge/ {print $(NF-1)}')
[33] Fix | Delete
BBU_OK=$(cat /home/nagios/raid_battery_level)
[34] Fix | Delete
if [ "$BBU_OK" -lt 80 ]; then
[35] Fix | Delete
[36] Fix | Delete
# The BBU charge is too low, try to force a relearn (the attempt will be logged in the raid controller logs)
[37] Fix | Delete
[38] Fix | Delete
if ! $MEGAPATH -AdpBbuCmd -BbuLearn -a0; then
[39] Fix | Delete
touch /home/nagios/bbu_relearn.error
[40] Fix | Delete
chown nagios:nagios /home/nagios/bbu_relearn.error
[41] Fix | Delete
else
[42] Fix | Delete
[43] Fix | Delete
[ -f /home/nagios/bbu_relearn.error ] && rm -f /home/nagios/bbu_relearn.error
[44] Fix | Delete
[45] Fix | Delete
touch /home/nagios/bbu_relearn.progress
[46] Fix | Delete
chown nagios:nagios /home/nagios/bbu_relearn.progress
[47] Fix | Delete
[48] Fix | Delete
# Touch a file to show when this relearn occurred
[49] Fix | Delete
touch "/home/nagios/.relearn.$(date +%s)"
[50] Fix | Delete
chown nagios:nagios "/home/nagios/.relearn.$(date +%s)"
[51] Fix | Delete
fi
[52] Fix | Delete
[53] Fix | Delete
else
[54] Fix | Delete
[55] Fix | Delete
echo "Battery is OK"
[56] Fix | Delete
exit 0
[57] Fix | Delete
[58] Fix | Delete
fi
[59] Fix | Delete
[60] Fix | Delete
fi
[61] Fix | Delete
[62] Fix | Delete
fi
[63] Fix | Delete
[64] Fix | Delete
fi
[65] Fix | Delete
[66] Fix | Delete
rm -f MegaSAS.log
[67] Fix | Delete
rm -f CtDbg.log
[68] Fix | Delete
[69] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function