chg: [backup and disk usage] to ALERT channel in send command
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Check if backup with rsync-backup is set and less than 24hours
|
## Check if backup with rsync-backup is set and less than 24hours
|
||||||
## Send warning threw NTFY
|
## 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"
|
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
|
## check if service exists in compose.yml
|
||||||
if ! grep -q "^rsync-backup" "$DEFAULT_COMPOSE_FILE"; then
|
if ! grep -q "^rsync-backup" "$DEFAULT_COMPOSE_FILE"; then
|
||||||
echo "no service rsync-backup - Ignoring."
|
echo "no service rsync-backup - Ignoring."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
last_backup_datetime=$(
|
last_backup_datetime=$(
|
||||||
@@ -47,6 +47,6 @@ timestamp=$(date +%s)
|
|||||||
time_difference=$((timestamp - last_backup_ts))
|
time_difference=$((timestamp - last_backup_ts))
|
||||||
days=$((time_difference / 86400))
|
days=$((time_difference / 86400))
|
||||||
hours=$((time_difference % 86400 / 3600))
|
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"
|
echo "$message" | logger -t "$LOGGER_TAG"
|
||||||
send -t "Backup" -c backup.warning "$message"
|
send -t "Backup" -c backup.alert "$message"
|
@@ -18,9 +18,9 @@ if [ "$percent_usage" -ge "90" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
touch $STATE_WORKING_DIR/disk_usage_90.state
|
touch $STATE_WORKING_DIR/disk_usage_90.state
|
||||||
message="CRITICAL : disk usage ${percent_usage}%"
|
message="ALERT : disk usage ${percent_usage}%"
|
||||||
echo "$message"
|
echo "$message"
|
||||||
send -c disk.crit "$message"
|
send -c disk.alert "$message"
|
||||||
fi
|
fi
|
||||||
elif [ "$percent_usage" -ge "75" ]; then
|
elif [ "$percent_usage" -ge "75" ]; then
|
||||||
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
|
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
|
||||||
@@ -28,7 +28,7 @@ elif [ "$percent_usage" -ge "75" ]; then
|
|||||||
else
|
else
|
||||||
touch $STATE_WORKING_DIR/disk_usage_75.state
|
touch $STATE_WORKING_DIR/disk_usage_75.state
|
||||||
message="WARNING disk usage is ${percent_usage}%"
|
message="WARNING disk usage is ${percent_usage}%"
|
||||||
send -c disk.alert "$message"
|
send -c disk.warning "$message"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
|
if [ -e $STATE_WORKING_DIR/disk_usage_75.state ]; then
|
||||||
|
Reference in New Issue
Block a user