From f487f6e39187c3a29fa45a16a888ed1e33d5947a Mon Sep 17 00:00:00 2001 From: Andrew Stowell Date: Wed, 22 Apr 2020 19:17:04 +0000 Subject: [PATCH] thermal scripts updated, crons only poll temp once, etc. --- .gitignore | 1 + crons/thermal-alert.sh | 18 ++++++++++++------ crons/thermal-log.sh | 6 ++++-- thermal.sh | 7 ++++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 0fe6ccb..11cdc7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /log/singleton.log /config.sh +/crons/*.status diff --git a/crons/thermal-alert.sh b/crons/thermal-alert.sh index d626689..2ff7ec7 100755 --- a/crons/thermal-alert.sh +++ b/crons/thermal-alert.sh @@ -4,12 +4,18 @@ LOCATION=`dirname "$0"` source "${LOCATION}/../config.sh" -if (( `cat /sys/class/thermal/thermal_zone0/temp` > ( $THERMAL_ALERT * 1000 ) )); then - echo "thermal above ${THERMAL_ALERT} C" - source "${LOCATION}/../thermal.sh" - ${LOCATION}/../discord.sh thermal `${LOCATION}/../thermal.sh` +thermal=`${LOCATION}/../thermal.sh ${THERMAL_ALERT}` +alert=$? + +if [[ "0" != "${alert}" ]]; then + echo "${thermal}, above threshold ${THERMAL_ALERT} C" + ${LOCATION}/../discord.sh thermal "${thermal}, above threshold ${THERMAL_ALERT} C" + touch "${LOCATION}/thermal.status" +elif [[ -f "${LOCATION}/thermal.status" ]]; then + rm "${LOCATION}/thermal.status" + echo "${thermal}, previously above threshold ${THERMAL_ALERT} C" + ${LOCATION}/../discord.sh thermal "${thermal}, previously above threshold ${THERMAL_ALERT} C" else - echo "thermal below ${THERMAL_ALERT} C" - source "${LOCATION}/../thermal.sh" + echo "${thermal}, below threshold ${THERMAL_ALERT} C" fi diff --git a/crons/thermal-log.sh b/crons/thermal-log.sh index 70986ae..ee1776a 100755 --- a/crons/thermal-log.sh +++ b/crons/thermal-log.sh @@ -2,6 +2,8 @@ LOCATION=`dirname "$0"` -source "${LOCATION}/../thermal.sh" -${LOCATION}/../discord.sh thermal `${LOCATION}/../thermal.sh` +thermal=`${LOCATION}/../thermal.sh` + +echo "${thermal}" +${LOCATION}/../discord.sh thermal "${thermal}" diff --git a/thermal.sh b/thermal.sh index c19dc6e..890c5cd 100755 --- a/thermal.sh +++ b/thermal.sh @@ -2,5 +2,10 @@ name=$( "0" )); then + exit `echo "$temp >= $1" | bc` +fi