chg: [backup and disk usage] to ALERT channel in send command

This commit is contained in:
Boris Gallet
2024-10-08 17:36:50 +02:00
parent 214763b7bb
commit dc5391c7cb
2 changed files with 7 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
## Check if backup with rsync-backup is set and less than 24hours
## Send warning threw NTFY
## log this in journalctl with logger `journactl -t backup`
## log this in journalctl with logger `journactl -t backup`
STATE_FILE="/var/run/elab-manage/backup.state"
@@ -14,7 +14,7 @@ source "/etc/compose/local.conf" || exit 1
## check if service exists in compose.yml
if ! grep -q "^rsync-backup" "$DEFAULT_COMPOSE_FILE"; then
echo "no service rsync-backup - Ignoring."
exit 0
exit 0
fi
last_backup_datetime=$(
@@ -47,6 +47,6 @@ timestamp=$(date +%s)
time_difference=$((timestamp - last_backup_ts))
days=$((time_difference / 86400))
hours=$((time_difference % 86400 / 3600))
message="WARNING: no backup done in the last 24h (No backup since $days days and $hours hours)"
message="ALERT: no backup done in the last 24h (No backup since $days days and $hours hours)"
echo "$message" | logger -t "$LOGGER_TAG"
send -t "Backup" -c backup.warning "$message"
send -t "Backup" -c backup.alert "$message"

View File

@@ -18,9 +18,9 @@ if [ "$percent_usage" -ge "90" ]; then
exit 0
else
touch $STATE_WORKING_DIR/disk_usage_90.state
message="CRITICAL : disk usage ${percent_usage}%"
message="ALERT : disk usage ${percent_usage}%"
echo "$message"
send -c disk.crit "$message"
send -c disk.alert "$message"
fi
elif [ "$percent_usage" -ge "75" ]; then
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
@@ -28,7 +28,7 @@ elif [ "$percent_usage" -ge "75" ]; then
else
touch $STATE_WORKING_DIR/disk_usage_75.state
message="WARNING disk usage is ${percent_usage}%"
send -c disk.alert "$message"
send -c disk.warning "$message"
fi
else
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then