# VPS RADS Tools, written by Erik Soroka (eriks@imhadmin.net, ext 834)
# this script gets executed by crontab to dump battery level to a file
#####################################################################
### CHECK AND STORE THE RAID CONTROLLER'S BATTERY LIFE
#####################################################################
MEGA64=/opt/MegaRAID/MegaCli/MegaCli64
MEGA32=/opt/MegaRAID/MegaCli/MegaCli
$MEGA64 -AdpBbuCmd -GetBbuStatus -aALL | awk '$0~/Relative State of Charge/ {print $(NF-1)}' > /home/nagios/raid_battery_level
elif [ -f $MEGA32 ]; then
$MEGA32 -AdpBbuCmd -GetBbuStatus -aALL | awk '$0~/Relative State of Charge/ {print $(NF-1)}' > /home/nagios/raid_battery_level
chown nagios.nagios /home/nagios/raid_battery_level