Update offsite-power-check.sh

This commit is contained in:
2023-11-05 21:22:36 -06:00
parent 4a129cbfc5
commit d4d3b2b0f9

View File

@@ -46,10 +46,7 @@ $(date)"
}
PWO_START(){
SENDNOTICE "OFFSITE POWER MONITOR" "Service starting
BATTERY: ${OFFSITE_BATT_CAP}'(percent)
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
startup=true
while true; do
upsinfo=$(upsc CP1500PFCLCD)
if [ "$(echo "${upsinfo}" | grep 'input.voltage:' | sed 's/.*: //')" != "" ]; then
@@ -57,12 +54,19 @@ VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
OFFSITE_BATT_RUNTIME=$(echo "${upsinfo}" | grep 'battery.runtime:' | sed 's/.*: //')
OFFSITE_BATT_RUNTIME=`echo "scale=2; ${OFFSITE_BATT_RUNTIME}/60" | bc`
OFFSITE_BATT_CAP=$(echo "${upsinfo}" | grep 'battery.charge:' | sed 's/.*: //')
if [ "${startup}" == "true" ]; then
SENDNOTICE "OFFSITE POWER MONITOR" "Service starting
BATTERY: ${OFFSITE_BATT_CAP}'(percent)
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"
startup=false
fi
if [ ${OFFSITE_VOLTIN%.*} -gt 105 ]; then
if [ -f ${PW_TMPFOLDER}/power.offsite.ac.low ]; then
if [ -f ${PW_TMPFOLDER}/power.offsite.off ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'Volts - ${OFFSITE_BATT_CAP}% Battery - Offsite Power Restored" >> ${PW_LOGPOWER}
SENDNOTICE "OFFSITE POWER" "Power restored! Will wait 5mins before turning host(s) back on.
SENDNOTICE "OFFSITE POWER" "Power restored! Will wait ${WAIT_TO_POWER_SERVERS}'Mins before turning host(s) back on.
BATTERY: ${OFFSITE_BATT_CAP}'(percent)
VOLTAGE: ${OFFSITE_VOLTIN}'Volts"