diff --git a/defaults.inc b/defaults.inc index debadff9..8da7bfba 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERS='2.5.282-02072024' +VERS='2.5.283-02072024' noheader=' update service dailytemp confsync -r -report ' diff --git a/inc/power.inc.sh b/inc/power.inc.sh index e27c14d7..fd413d7c 100644 --- a/inc/power.inc.sh +++ b/inc/power.inc.sh @@ -620,7 +620,7 @@ OFFSITE_CHECKPOWER_SERVICE(){ fi - SENDNOTICE(){ + SENDNOTICE2(){ MESSAGE="${TESTMODE}${2} BATTERY CHARGE: ${OFFSITE_BATT_CAP}'% @@ -630,14 +630,14 @@ WATT USAGE: ${OFFSITE_WATTS}'watts AMBIENT TEMP: ${OFFSITE_TEMP}'F $(date)" - MESSAGE="$(echo -e "${2}" | sed "s/\%/\%25 /g")" + MESSAGE="$(echo -e "${MESSAGE}" | sed "s/\%/\%25 /g")" if [ "${3}" = "1" ]; then PRIORITY="${3}"; MSGSOUND=siren; elif [ "${3}" != "" ]; then PRIORITY=${3}; else PRIORITY=0; fi curl -m 3 -sd "token=${PW_PUSHOVER_APP_TOKEN}&user=${PW_PUSHOVER_USER_TOKEN}&message=$(echo "${MESSAGE}" | sed -e "s/%/%25/g")&title=${1}&priority=${PRIORITY}&sound=cosmic" https://api.pushover.net/1/messages.json >/dev/null 2>&1 } if [ "${startup}" = "true" ]; then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_WATTS}'watts - ${OFFSITE_BATT_CAP}'% Battery - ${OFFSITE_BATT_RUNTIME}'mins - Service startup" >> ${PW_LOGPOWER} echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Service startup" >> ${PW_LOGFILE} - # SENDNOTICE "OFFSITE POWER SERVICE STARTUP" "Service starting" + # SENDNOTICE2 "OFFSITE POWER SERVICE STARTUP" "Service starting" OFFSITE_SENDPOWER "OFFSITE POWER Service Startup" & startup=false fi @@ -645,7 +645,7 @@ $(date)" if [ ${OFFSITE_VOLTIN%.*} -gt 105 ]; then if [ -f ${PW_TMPFOLDER}/power.offsite.charging ] && [ ${OFFSITE_BATT_CAP%.*} -eq 100 ]; then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Charging Complete" >> ${PW_LOGFILE} - SENDNOTICE "OFFSITE POWER" "Batteries are fully recharged" + SENDNOTICE2 "OFFSITE POWER" "Batteries are fully recharged" rm -f ${PW_TMPFOLDER}/power.offsite.charging # elif [ ${OFFSITE_BATT_CAP%.*} -lt 100 ] && [ ! -f ${PW_TMPFOLDER}/power.offsite.charging ]; then elif [ ${OFFSITE_BATT_CAP%.*} -lt 100 ] && ([ ! -f ${PW_TMPFOLDER}/power.offsite.charging ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.charging)) -gt 60 ]); then @@ -655,7 +655,7 @@ $(date)" if [ -f ${PW_TMPFOLDER}/power.offsite.ac.low ]; then if [ -f ${PW_TMPFOLDER}/shutdown.OFFSITE ]; then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Offsite Power Restored" >> ${PW_LOGFILE} - SENDNOTICE "OFFSITE POWER" "Power restored! Will wait ${PW_OFFSITE_WAIT_TO_POWER_SERVERS}'mins before turning host(s) back on" + SENDNOTICE2 "OFFSITE POWER" "Power restored! Will wait ${PW_OFFSITE_WAIT_TO_POWER_SERVERS}'mins before turning host(s) back on" fi rm -f ${PW_TMPFOLDER}/power.offsite.ac.* @@ -666,7 +666,7 @@ $(date)" elif [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.restored)) -gt $(echo "scale=2; ${PW_OFFSITE_WAIT_TO_POWER_SERVERS}*60" | bc) ]; then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Powering Hosts ON After Power Outage" >> ${PW_LOGFILE} - SENDNOTICE "OFFSITE HOST POWER" "Powering offsite host(s) back ONLINE after power outage" + SENDNOTICE2 "OFFSITE HOST POWER" "Powering offsite host(s) back ONLINE after power outage" for host in ${PW_OFFSITEHOSTS_IDRAC}; do if [ "${TEST}" = "" ] || [ "${TEST}" = "full" ]; then ipmitool -I lanplus -H ${host} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power on & @@ -687,13 +687,13 @@ $(date)" if [ ! -f ${PW_TMPFOLDER}/power.offsite.ac.low.notice ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.ac.low.notice)) -gt $(echo "scale=2; ${PW_RENOTIFY_LOWPOWER}*60" | bc) ]; then # echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Powering LOW/OFF!" >> ${PW_LOGFILE} - SENDNOTICE "OFFSITE POWER - POWER OFF/LOW!!" "Power off or low voltage detected" 1 + SENDNOTICE2 "OFFSITE POWER - POWER OFF/LOW!!" "Power off or low voltage detected" 1 touch ${PW_TMPFOLDER}/power.offsite.ac.low.notice fi if [ ! -f ${PW_TMPFOLDER}/shutdown.OFFSITE ] && [ ${OFFSITE_WATTS%.*} -gt 100 ] && ([ ${OFFSITE_BATT_CAP%.*} -le ${PW_OFFSITE_SHUTDOWNSERVERS_AT_LOAD} ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.ac.low)) -ge $(echo "scale=2; ${PW_OFFSITE_SHUTDOWNSERVERS_AFTER}*60" | bc) ]); then echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Powering Down Hosts!" >> ${PW_LOGFILE} - SENDNOTICE "OFFSITE HOST POWER" "Powering DOWN offsite host(s) due to power outage" 1 + SENDNOTICE2 "OFFSITE HOST POWER" "Powering DOWN offsite host(s) due to power outage" 1 touch ${PW_TMPFOLDER}/shutdown.OFFSITE for host in ${PW_OFFSITEHOSTS}; do if [ "${TEST}" = "" ] || [ "${TEST}" = "full" ]; then @@ -712,7 +712,7 @@ $(date)" elif [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.ups.losscomm)) -ge 120 ]; then echo "($(date +'%Y-%m-%d %H:%M:%S')) - 0.0'volts - 0'% Battery - Restarting NUT service" >> ${PW_LOGFILE} - SENDNOTICE "NUT DRIVER FAILURE" "OMG WHAT DO WE DO, FIX ME!!! I used to be cool and say..... Restarting NUT service" + SENDNOTICE2 "NUT DRIVER FAILURE" "OMG WHAT DO WE DO, FIX ME!!! I used to be cool and say..... Restarting NUT service" # /usr/local/etc/rc.d/nut.sh restart # sleep 10s touch ${PW_TMPFOLDER}/power.ups.losscomm @@ -1014,7 +1014,7 @@ SENDPOWER(){ OFFSITE_SENDPOWER(){ st_power=`${PW_SCRIPT} check power -o -p -r` - SENDNOTICE "${1}" "${st_power}" + SENDNOTICE2 "${1}" "${st_power}" }