From 521bbaa669a1091438dae0d610d1ee1b2ae79260 Mon Sep 17 00:00:00 2001 From: vishnubish1255 Date: Mon, 13 Apr 2026 02:54:12 +0530 Subject: [PATCH] fix-disk-alert-script --- scripts/disk-alert | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/disk-alert b/scripts/disk-alert index ab1cc55..71155e0 100644 --- a/scripts/disk-alert +++ b/scripts/disk-alert @@ -9,7 +9,7 @@ THRESHOLD=90 # Example starting point: # USAGE=$(df -h / | awk 'NR==2 {print $5}') # Next, remove the '%' sign using `tr -d '%'` so you have a plain integer. -USAGE="" +USAGE=$(df -h / | awk 'NR==2 {print $5}' | tr -d '%') if [ -z "$USAGE" ]; then echo "Could not fetch disk usage, please implement the TODO!" @@ -22,3 +22,9 @@ echo "Current root disk usage is at $USAGE%" # If it is, echo a "WARNING: Disk space low!" message. # If not, echo an "All good: Plenty of space." message. +if [ "$USAGE" -ge "$THRESHOLD" ]; then + echo "WARNING: Disk space low!" +else + echo "All good: Plenty of space." +fi +