From 8da3e98c831cfe123ec6433a0e6bc5fa73f63cc1 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Tue, 19 Mar 2024 06:28:02 +0100 Subject: [PATCH] figure --- check-disk-space.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 check-disk-space.sh diff --git a/check-disk-space.sh b/check-disk-space.sh new file mode 100755 index 00000000..a831fc6b --- /dev/null +++ b/check-disk-space.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Threshold for disk usage percentage +threshold=90 + +# Get the list of mounted filesystems and their usage +filesystems=$(df -h --output=target,pcent | tail -n +2) + +# Iterate over each line of the output +while IFS= read -r line; do + # Extract filesystem and usage percentage + 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!" + fi +done <<< "$filesystems"