A “quick&dirty” script to check FS usage on a Linux machine. If above a certain threshold it is possibile to define any action (e.g. send an email)
#!/bin/bash
FS=$1
THRESHOLD=$2
echo “Checking Filesystem ” $FS “with threshold “$THRESHOLD
SIZE=$(df -h $FS | grep $FS | awk ‘{print $1}’)
USED=$(df -h $FS | grep $FS | awk ‘{print $2}’)
AVAIL=$(df -h $FS | grep $FS | awk ‘{print $3}’)
PERC_USAGE=$(df -h $FS | grep $FS | awk ‘{print $4}’)
echo “Size: ” $SIZE
echo “Used: ” $USED
echo “Avail: ” $AVAIL
echo “Perc Usage: ” $PERC_USAGE
PERC=$(echo $PERC_USAGE | awk -F’%’ ‘{print $1}’)
if [[ $PERC -gt $THRESHOLD ]]
then
echo “Filesystem Usage above threshold!!!”
fi