This commit is contained in:
2025-06-03 18:05:21 -05:00
parent d7c2543800
commit 79a2ce21db
2 changed files with 28 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
PW_VERS='2.10.12-06032025'
PW_VERS='2.10.13-06032025'
noheader=' update service dailytemp confsync -r -report test '

View File

@@ -1024,18 +1024,35 @@ OFFSITE_CHECKPOWER_SERVICE(){
(( $(bc <<<"${OFFSITE_WATTS} < ${TOTAL_MISC_WATTS}") )) && OFFSITE_WATTS=${TOTAL_MISC_WATTS}
fi
if [ ! -d /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']} ]; then
/bin/dtoverlay w1-gpio gpiopin=4
sleep 2s
fi
if [ -d /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']} ]; then
temp_c=$(cat /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']}/w1_slave | tail -n1 | cut -d "=" -f2)
OFFSITE_TEMP=$(bc <<< "scale=2; ((${temp_c}/1000)*(9/5))+32")
if [ "${PW_OFFSITE_MONITOR}" == "${IP}" ]; then
if [ ! -d /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']} ]; then
/bin/dtoverlay w1-gpio gpiopin=4
sleep 2s
fi
if [ -d /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']} ]; then
temp_c=$(cat /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']}/w1_slave | tail -n1 | cut -d "=" -f2)
OFFSITE_TEMP=$(bc <<< "scale=2; ((${temp_c}/1000)*(9/5))+32")
else
OFFSITE_TEMP=ERR
fi
else
OFFSITE_TEMP=ERR
if ${SSHCMD} root@${PW_OFFSITE_MONITOR} [ ! -d /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']} ]; then
${SSHCMD} root@${PW_OFFSITE_MONITOR} '/bin/dtoverlay w1-gpio gpiopin=4'
sleep 2s
fi
if ${SSHCMD} root@${PW_OFFSITE_MONITOR} [ -d /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']} ]; then
temp_c=$(${SSHCMD} root@${PW_OFFSITE_MONITOR} cat /sys/bus/w1/devices/${PW_SENSOR_DEVICEID['Offsite-ServerRoom']}/w1_slave | tail -n1 | cut -d "=" -f2)
OFFSITE_TEMP=$(bc <<< "scale=2; ((${temp_c}/1000)*(9/5))+32")
else
OFFSITE_TEMP=ERR
fi
fi
SENDNOTICE2(){
MESSAGE="${TESTMSG}${2}
@@ -1136,15 +1153,14 @@ AMBIENT TEMP: ${OFFSITE_TEMP}'F"
elif [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/power.offsite.ups.losscomm)) -ge 120 ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - 0.0'V - 0'% Battery - Restarting NUT service" >> ${PW_LOGFILE}
echo "HERE2: $upsinfo"
# systemctl restart /usr/lib/systemd/system/nut-driver.service
[ "${PW_OFFSITE_MONITOR}" == "${IP}" ] && systemctl restart nut-driver || ${SSHCMD} root@${PW_OFFSITE_MONITOR} 'systemctl restart nut-driver'
sleep 10s
touch ${PW_TMPFOLDER}/power.offsite.ups.losscomm
fi
fi
end=`date +%s`; runtime=$((end-start))
# echo -e "script runtime: ${runtime}s"; [ ${runtime} -lt ${runEvery} ] && echo "Sleeping for $(expr ${runEvery} - ${runtime})s"
echo -e "script runtime: ${runtime}s"; [ ${runtime} -lt ${runEvery} ] && echo "Sleeping for $(expr ${runEvery} - ${runtime})s"
echo "${log_start}~${runtime}~offsite-power" >> ${PW_LOGFOLDER}/service.scantimes
[ ${runtime} -lt ${runEvery} ] && sleep $(expr ${runEvery} - ${runtime})s ###|| echo "Not sleeping, ran for ${runtime}s previsoulsy"
done