diff --git a/crons/storage-alert.sh b/crons/storage-alert.sh index d21bcf2..343cfda 100755 --- a/crons/storage-alert.sh +++ b/crons/storage-alert.sh @@ -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 diff --git a/crons/storage-log.sh b/crons/storage-log.sh index 99d5096..4defe78 100755 --- a/crons/storage-log.sh +++ b/crons/storage-log.sh @@ -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 diff --git a/crons/thermal-alert.sh b/crons/thermal-alert.sh index 432d8cf..74f9f3a 100755 --- a/crons/thermal-alert.sh +++ b/crons/thermal-alert.sh @@ -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 diff --git a/crons/thermal-log.sh b/crons/thermal-log.sh index 6d90895..2ac0f44 100755 --- a/crons/thermal-log.sh +++ b/crons/thermal-log.sh @@ -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 diff --git a/thermal.sh b/thermal.sh index ae50f94..b849354 100755 --- a/thermal.sh +++ b/thermal.sh @@ -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" zone temp (milli-celsius) # "./type" 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