updated storage and thermal crons to work with ntfy, and fixed thermal to not give errors when there is no thermal data to work with
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
locations="$@"
|
||||
hostname=$(hostname)
|
||||
|
||||
# load in defaults from config
|
||||
scriptRoot="$(dirname "$0")/.."
|
||||
@@ -29,16 +30,16 @@ done
|
||||
|
||||
if [[ "${warn}" = true ]]; then
|
||||
color='purple'
|
||||
title='Storage Alert'
|
||||
title="Storage alert on $hostname"
|
||||
touch "${HOME}/.storage.alert"
|
||||
elif [[ -f "${HOME}/.storage.alert" ]]; then
|
||||
color='blue'
|
||||
title='Storage Alert Resolved'
|
||||
title="Storage resolved on $hostname"
|
||||
rm "${HOME}/.storage.alert"
|
||||
else
|
||||
# no storage alerts, exit quietly
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "%s\n" "${messages[@]}" | "${scriptRoot}/discord.sh" -a -c "${color}" -t "${title}"
|
||||
printf "%s\n" "${messages[@]}" | ntfy pub -T "${color}_square" -t "$title" storage
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
locations="$@"
|
||||
hostname=$(hostname)
|
||||
|
||||
# load in defaults from config
|
||||
scriptRoot="$(dirname "$0")/.."
|
||||
@@ -13,5 +14,5 @@ if [[ -f "${configFile}" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
"${scriptRoot}/df.sh" $locations | "${scriptRoot}/discord.sh" -c 'blue' -t 'Storage Status'
|
||||
"${scriptRoot}/df.sh" $locations | ntfy pub -T blue_square -t "Storage status on $hostname" storage
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
# degrees in Celsius which we regard as too high, defaults to config
|
||||
alertLevel="$1"
|
||||
hostname=$(hostname)
|
||||
|
||||
# load in defaults from config
|
||||
scriptRoot="$(dirname "$0")/.."
|
||||
@@ -21,12 +22,12 @@ alert="$?"
|
||||
if [[ '0' -ne "${alert}" ]]; then
|
||||
# if currently in an alert status
|
||||
alertLevelF=$(echo "scale=1 ; ${alertLevel} * 9 / 5 + 32" | bc -l)
|
||||
"${scriptRoot}/discord.sh" -a -c red -t 'Thermal Alert' "${thermal}" $'\n' "above threshold ${alertLevel} C (${alertLevelF} F)"
|
||||
ntfy pub -T red_square -t "Thermal alert on $hostname" thermal "${thermal}" $'\n' "above threshold ${alertLevel} C (${alertLevelF} F)"
|
||||
touch "${HOME}/.thermal.alert"
|
||||
elif [[ -f "${HOME}/.thermal.alert" ]]; then
|
||||
# if previously in an alert status
|
||||
alertLevelF=$(echo "scale=1 ; ${alertLevel} * 9 / 5 + 32" | bc -l)
|
||||
"${scriptRoot}/discord.sh" -a -c orange -t 'Thermal Alert' "${thermal}" $'\n' "previously above threshold ${alertLevel} C (${alertLevelF} F)"
|
||||
ntfy pub -T orange_square -t "Thermal alert on $hostname" thermal "${thermal}" $'\n' "previously above threshold ${alertLevel} C (${alertLevelF} F)"
|
||||
rm "${HOME}/.thermal.alert"
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
scriptRoot="$(dirname "$0")/.."
|
||||
hostname=$(hostname)
|
||||
|
||||
"${scriptRoot}/thermal.sh" | "${scriptRoot}/discord.sh" -c yellow -t 'Thermal Status'
|
||||
# get current status
|
||||
thermal=$(${scriptRoot}/thermal.sh)
|
||||
|
||||
if [[ -n "$thermal" ]]; then
|
||||
ntfy pub -T yellow_square -t "Thermal status on $hostname" thermal
|
||||
fi
|
||||
|
||||
|
||||
+6
-1
@@ -15,6 +15,11 @@ fi
|
||||
|
||||
# loop over all thermal zones
|
||||
while read -r mcFile; do
|
||||
# we need something to work with
|
||||
if [[ -z "$mcFile" ]]; then
|
||||
continue;
|
||||
fi
|
||||
|
||||
# each zone has two files we use:
|
||||
# "./temp" <int> zone temp (milli-celsius)
|
||||
# "./type" <string> zone title
|
||||
@@ -34,7 +39,7 @@ while read -r mcFile; do
|
||||
alertActive=1
|
||||
fi
|
||||
|
||||
done <<< $(find /sys/class/thermal/thermal*/ -name 'temp')
|
||||
done <<< $(find /sys/class/thermal/*/* -path '*/thermal_*' -name 'temp')
|
||||
|
||||
# we exit with a status code of 1 to indicate alert level has been reached
|
||||
if [[ "$alertActive" -eq 1 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user