update
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERS='2.161-08122023'
|
VERS='2.162-08122023'
|
||||||
|
|
||||||
noheader=' update service dailytemp '
|
noheader=' update service dailytemp '
|
||||||
|
|
||||||
|
|||||||
48
powerwall.sh
48
powerwall.sh
@@ -59,11 +59,14 @@ CHECKTEMPSENSOR(){
|
|||||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
|
|
||||||
elif [ "${SENSOR_TYPE[${1}]}" == "remotesystem" ]; then
|
elif [ "${SENSOR_TYPE[${1}]}" == "remotesystem" ]; then
|
||||||
|
if [ "$(CHECK_HOST ${REMOTE_SENSORS[${1}]})" != "false" ]; then
|
||||||
temp_c=$(ssh root@${REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
|
temp_c=$(ssh root@${REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
|
||||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
||||||
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
||||||
#echo "$temp_c -> $temp_f"
|
#echo "$temp_c -> $temp_f"
|
||||||
@@ -117,6 +120,14 @@ CHECKTEMP_SERVICE(){
|
|||||||
errtime=$(expr `date +%s` - $(stat -c %Y ${logtemp}))
|
errtime=$(expr `date +%s` - $(stat -c %Y ${logtemp}))
|
||||||
[ $errtime -ge 3600 ] && relog=1 || relog=0
|
[ $errtime -ge 3600 ] && relog=1 || relog=0
|
||||||
|
|
||||||
|
if [ "$(CHECK_HOST ${REMOTE_SENSORS[${1}]})" != "false" ]; then
|
||||||
|
if [ -f ${TMPFOLDER}/${SENSOR}.down ]; then
|
||||||
|
SENDNOTICE "${SENSOR} Online" "${SENSOR} is back online"
|
||||||
|
echo "($datetime) - ${SENSOR} - ${SENSOR} is back onlione" >> ${logtemp}
|
||||||
|
rm -f ${TMPFOLDER}/${SENSOR}.down
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${SENSOR_TYPE[${SENSOR}]}" == "mqtt" ]; then
|
if [ "${SENSOR_TYPE[${SENSOR}]}" == "mqtt" ]; then
|
||||||
mqtt_message=`${mqtt_conn} -t tele/${SENSOR}/SENSOR -C 1`
|
mqtt_message=`${mqtt_conn} -t tele/${SENSOR}/SENSOR -C 1`
|
||||||
echo $mqtt_message | cut -d':' -f 7 | cut -d',' -f 1 | read temp_h
|
echo $mqtt_message | cut -d':' -f 7 | cut -d',' -f 1 | read temp_h
|
||||||
@@ -126,10 +137,22 @@ CHECKTEMP_SERVICE(){
|
|||||||
temp_c=$(vcgencmd measure_temp)
|
temp_c=$(vcgencmd measure_temp)
|
||||||
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
temp_h=''
|
temp_h=''
|
||||||
|
|
||||||
|
elif [ "${SENSOR_TYPE[${SENSOR}]}" == "remotesystem" ]; then
|
||||||
|
temp_c=$(ssh root@${REMOTE_SENSORS[${1}]} vcgencmd measure_temp)
|
||||||
|
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
|
||||||
|
temp_h=''
|
||||||
|
|
||||||
fi
|
fi
|
||||||
datetime=`date +'%Y-%m-%d %H:%M:%S'`
|
datetime=`date +'%Y-%m-%d %H:%M:%S'`
|
||||||
|
|
||||||
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
|
||||||
|
if [ -f ${TMPFOLDER}/${SENSOR}-error.reading ]; then
|
||||||
|
SENDNOTICE "${SENSOR} Data" "${SENSOR} is reporting data again"
|
||||||
|
echo "($datetime) - ${SENSOR} - ${SENSOR} is reporting data again" >> ${logtemp}
|
||||||
|
rm -f ${TMPFOLDER}/${SENSOR}-error.reading
|
||||||
|
|
||||||
|
fi
|
||||||
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
|
||||||
|
|
||||||
echo ${TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 1 | read temp_warn
|
echo ${TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 1 | read temp_warn
|
||||||
@@ -157,7 +180,7 @@ CHECKTEMP_SERVICE(){
|
|||||||
touch ${TMPFOLDER}/temp.crit
|
touch ${TMPFOLDER}/temp.crit
|
||||||
if [ $temp_diff -gt 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then
|
if [ $temp_diff -gt 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then
|
||||||
SENDNOTICE "${SENSOR} TEMP CRITICAL" "($datetime) CRITICAL TEMP: ${temp_f}'F - (Difference of ${temp_diff}')
|
SENDNOTICE "${SENSOR} TEMP CRITICAL" "($datetime) CRITICAL TEMP: ${temp_f}'F - (Difference of ${temp_diff}')
|
||||||
Shutting down servers!!" 1
|
Shutting down servers!!" 1
|
||||||
echo "($datetime) - ${temp_f}'F - CRITICAL - (Difference of ${temp_diff}'F)" >> ${logtemp}
|
echo "($datetime) - ${temp_f}'F - CRITICAL - (Difference of ${temp_diff}'F)" >> ${logtemp}
|
||||||
echo "($datetime) - ${temp_f}'F - alert sent" >> ${logtemp}
|
echo "($datetime) - ${temp_f}'F - alert sent" >> ${logtemp}
|
||||||
echo -e "($datetime) - ${SENSOR} - ${temp_f}'F - CRITICAL TEMP - (Difference of ${temp_diff}')" >> ${logfile}
|
echo -e "($datetime) - ${SENSOR} - ${temp_f}'F - CRITICAL TEMP - (Difference of ${temp_diff}')" >> ${logfile}
|
||||||
@@ -170,7 +193,7 @@ Shutting down servers!!" 1
|
|||||||
touch ${TMPFOLDER}/temp.critsys
|
touch ${TMPFOLDER}/temp.critsys
|
||||||
if [ $temp_diff -gt 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then
|
if [ $temp_diff -gt 1 ] || [ "${last_temp[${SENSOR}]}" = "1" ]; then
|
||||||
SENDNOTICE "${SENSOR} TEMP CRITICAL" "($datetime) SYSTEM CRITICAL TEMP: ${temp_f}'F - (Difference of ${temp_diff}')
|
SENDNOTICE "${SENSOR} TEMP CRITICAL" "($datetime) SYSTEM CRITICAL TEMP: ${temp_f}'F - (Difference of ${temp_diff}')
|
||||||
Shutting down system servers!!" 1
|
Shutting down system servers!!" 1
|
||||||
echo "($datetime) - ${temp_f}'F - SYSTEM CRITICAL - (Difference of ${temp_diff})" >> ${logtemp}
|
echo "($datetime) - ${temp_f}'F - SYSTEM CRITICAL - (Difference of ${temp_diff})" >> ${logtemp}
|
||||||
echo "($datetime) - ${temp_f}'F - alert sent" >> ${logtemp}
|
echo "($datetime) - ${temp_f}'F - alert sent" >> ${logtemp}
|
||||||
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - CRITICAL TEMP SYSTEM - (Difference of ${temp_diff}')" >> ${logfile}
|
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - CRITICAL TEMP SYSTEM - (Difference of ${temp_diff}')" >> ${logfile}
|
||||||
@@ -184,7 +207,7 @@ Shutting down system servers!!" 1
|
|||||||
|
|
||||||
if [ ${last_temp[${SENSOR}]} -gt 1 ]; then
|
if [ ${last_temp[${SENSOR}]} -gt 1 ]; then
|
||||||
SENDNOTICE "${SENSOR} BACK TO NORMAL" "($datetime) NORMAL TEMP: ${temp_f}'F
|
SENDNOTICE "${SENSOR} BACK TO NORMAL" "($datetime) NORMAL TEMP: ${temp_f}'F
|
||||||
Previous Temp: ${last_temp[${SENSOR}]}'F"
|
Previous Temp: ${last_temp[${SENSOR}]}'F"
|
||||||
echo -e "($datetime) - ${temp_f}'F - Back to NORMAL TEMP - Previous Temp: ${last_temp[${SENSOR}]}'F" >> ${logtemp}
|
echo -e "($datetime) - ${temp_f}'F - Back to NORMAL TEMP - Previous Temp: ${last_temp[${SENSOR}]}'F" >> ${logtemp}
|
||||||
echo "($datetime) - ${temp_f}'F - alert sent" >> ${logtemp}
|
echo "($datetime) - ${temp_f}'F - alert sent" >> ${logtemp}
|
||||||
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - Back to NORMAL TEMP" >> ${logfile}
|
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - Back to NORMAL TEMP" >> ${logfile}
|
||||||
@@ -192,7 +215,7 @@ Previous Temp: ${last_temp[${SENSOR}]}'F"
|
|||||||
|
|
||||||
elif [ ${last_temp[${SENSOR}]} -eq 0 ]; then
|
elif [ ${last_temp[${SENSOR}]} -eq 0 ]; then
|
||||||
SENDNOTICE "${SENSOR} TEMP NORMAL" "($datetime) Service Startup
|
SENDNOTICE "${SENSOR} TEMP NORMAL" "($datetime) Service Startup
|
||||||
NORMAL TEMP: ${temp_f}'F"
|
NORMAL TEMP: ${temp_f}'F"
|
||||||
echo -e "($datetime) - ${temp_f}'F - Service Startup - NORMAL TEMP" >> ${logtemp}
|
echo -e "($datetime) - ${temp_f}'F - Service Startup - NORMAL TEMP" >> ${logtemp}
|
||||||
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - Service Startup" >> ${logfile}
|
echo -e "($datetime) - ${temp_f}'F - ${SENSOR} - Service Startup" >> ${logfile}
|
||||||
[ "$(compgen -G "${FOLDER}/shutdown.*")" != "" ] && rm -f ${FOLDER}/shutdown.*
|
[ "$(compgen -G "${FOLDER}/shutdown.*")" != "" ] && rm -f ${FOLDER}/shutdown.*
|
||||||
@@ -221,8 +244,21 @@ NORMAL TEMP: ${temp_f}'F"
|
|||||||
touch ${TMPFOLDER}/${SENSOR}.insert
|
touch ${TMPFOLDER}/${SENSOR}.insert
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
SENDNOTICE "${SENSOR} ERROR" "($datetime) ERROR reading temperature" 1
|
if [ ! -f ${TMPFOLDER}/${SENSOR}-error.reading ] || [ $(expr `date +%s` - $(stat -c %Y ${TMPFOLDER}/${SENSOR}-error.reading)) -ge 1800 ]; then
|
||||||
echo "($datetime) - alert sent" >> ${logtemp}
|
SENDNOTICE "${SENSOR} ERROR" "($datetime) ERROR reading sensor data" 1
|
||||||
|
echo "($datetime) - ${SENSOR} - ERROR reading sensor data" >> ${logtemp}
|
||||||
|
touch ${TMPFOLDER}/${SENSOR}-error.reading
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ ! -f ${TMPFOLDER}/${SENSOR}.down ] || [ $(expr `date +%s` - $(stat -c %Y ${TMPFOLDER}/${SENSOR}.down)) -ge 1800 ]; then
|
||||||
|
SENDNOTICE "${SENSOR} ERROR" "${SENSOR} is down" 1
|
||||||
|
echo "($datetime) - ${SENSOR} - ${SENSOR} is down" >> ${logtemp}
|
||||||
|
touch ${TMPFOLDER}/${SENSOR}.down
|
||||||
|
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user