From 48c1360554f30c22600115f02ff599ae50fa85f1 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Tue, 19 Mar 2024 06:29:32 +0100 Subject: [PATCH] fix --- check-disk-space.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/check-disk-space.sh b/check-disk-space.sh index a831fc6b..e2115c88 100755 --- a/check-disk-space.sh +++ b/check-disk-space.sh @@ -12,8 +12,13 @@ while IFS= read -r line; do filesystem=$(echo "$line" | awk '{print $1}') usage=$(echo "$line" | awk -F'%' '{print $1}') - # Check if usage is above the threshold - if [ "$usage" -ge "$threshold" ]; then - echo "WARNING: Filesystem $filesystem is $usage% full!" + # Check if usage is a number + if [[ $usage =~ ^[0-9]+$ ]]; then + # Check if usage is above the threshold + if [ "$usage" -ge "$threshold" ]; then + echo "WARNING: Filesystem $filesystem is $usage% full!" + fi + else + echo "WARNING: Unable to parse usage for filesystem $filesystem." fi done <<< "$filesystems"