new discord script, takes color, title, also accepts distinct.

This commit is contained in:
2023-11-09 21:08:00 +00:00
parent e5543afc9b
commit f74ac68554
8 changed files with 291 additions and 88 deletions
+26 -9
View File
@@ -1,16 +1,33 @@
#!/bin/bash
LOCATION=`dirname "$0"`
backupDir="$1"
backupType="$2"
source "${LOCATION}/../config.sh"
# load in defaults from config
scriptRoot="$(dirname "$0")/.."
configFile="$scriptRoot/config.sh"
if [[ -f "$configFile" ]]; then
source "$configFile"
cd "${BACKUP_DIRECTORY}"
if [[ -z "$backupDir" ]]; then
backupDir="$BACKUP_DIRECTORY"
fi
if [[ -z "$backupType" ]]; then
backupType="$PRUNE_TYPE"
fi
fi
backups=`find * -type f | sort | xargs du -h`
echo "${backups}"
${LOCATION}/../discord.sh block "${backups}"
if [[ "$backupType" = "<DIR>" ]]; then
backups=$(find "$backupDir" -maxdepth 1 -type d | grep -v "^$backupDir$" | sort | xargs du -h --summarize)
hashes=""
else
backups=$(find "$backupDir" -type f -name "$backupType" | sort | xargs du -h)
hashes=$(find "$backupDir" -type f -name "$backupType" | sort | xargs md5sum --tag)
fi
hashes=`find * -type f | sort | xargs md5sum --tag`
echo "${hashes}"
${LOCATION}/../discord.sh block "${hashes}"
echo "$backups"
if [[ -n "$hashes" ]]; then
echo "$hashes"
fi
"$scriptRoot/discord.sh" -c "mint" -t "Backup Status" "$backups" "$hashes"
+27 -15
View File
@@ -1,23 +1,35 @@
#!/bin/bash
LOCATION=`dirname "$0"`
locations="$@"
source "${LOCATION}/../config.sh"
# load in defaults from config
scriptRoot="$(dirname "$0")/.."
configFile="$scriptRoot/config.sh"
if [[ -f "$configFile" ]]; then
source "$configFile"
COUNT=1
for index in "${!STORAGE_ALERT[@]}"; do
storage=`${LOCATION}/../storage.sh $index ${STORAGE_ALERT[$index]}`
alert=$?
if [[ "0" != "${alert}" ]]; then
echo "${storage} is below threshold ${STORAGE_ALERT[$index]}G"
${LOCATION}/../discord-if-distinct.sh block "storage-${COUNT}" "${storage} is below threshold ${STORAGE_ALERT[$index]}G"
else
echo "${storage} is above threshold ${STORAGE_ALERT[$index]}G"
${LOCATION}/../discord-if-distinct.sh block "storage-${COUNT}" "${storage} is above threshold ${STORAGE_ALERT[$index]}G"
if [[ -z "$locations" ]]; then
locations=${STORAGE_MONITOR[@]}
fi
fi
let "COUNT++"
warn=false
messages=()
for index in "${!STORAGE_ALERT[@]}"; do
storage=$("$scriptRoot/storage.sh" "$index" "${STORAGE_ALERT[$index]}")
alert="$?"
if [[ "0" != "$alert" ]]; then
warn=true
messages+=("$storage is below threshold ${STORAGE_ALERT[$index]}G")
else
messages+=("$storage is above threshold ${STORAGE_ALERT[$index]}G")
fi
done
if [[ "$warn" = true ]]; then
purple="purple"
fi
printf "%s\n" "${messages[@]}"
printf "%s\n" "${messages[@]}" | "$scriptRoot/discord.sh" -c "${purple-blue}" -d "Storage Alert"
+11 -5
View File
@@ -1,11 +1,17 @@
#!/bin/bash
LOCATION=`dirname "$0"`
locations="$@"
source "${LOCATION}/../config.sh"
# load in defaults from config
scriptRoot="$(dirname "$0")/.."
configFile="$scriptRoot/config.sh"
if [[ -f "$configFile" ]]; then
source "$configFile"
storage=`${LOCATION}/../df-custom.sh ${STORAGE_MONITOR[@]}`
if [[ -z "$locations" ]]; then
locations=${STORAGE_MONITOR[@]}
fi
fi
echo "${storage}"
${LOCATION}/../discord.sh block "${storage}"
"$scriptRoot/df-custom.sh" $locations | "$scriptRoot/discord.sh" -c "blue" -t "Storage Status"
+2 -2
View File
@@ -21,12 +21,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" "$thermal, above threshold $alertLevel C ($alertLevelF F)"
"$scriptRoot/discord.sh" -c "red" -t "Thermal Alert" "$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" "$thermal, previously above threshold $alertLevel C ($alertLevelF F)"
"$scriptRoot/discord.sh" -c "orange" -t "Thermal Alert" "$thermal" $'\n' "previously above threshold $alertLevel C ($alertLevelF F)"
rm "$HOME/.thermal.alert"
fi
+1 -3
View File
@@ -2,7 +2,5 @@
scriptRoot="$(dirname "$0")/.."
thermal=$("$scriptRoot/thermal.sh")
"$scriptRoot/discord.sh" "$thermal"
"$scriptRoot/thermal.sh" | "$scriptRoot/discord.sh" -c "yellow" -t "Thermal Status"