topical media & game development
basic-shell-13-diskcheck.sh / sh
#!/bin/sh
# Output warnings if disks are too full (in percentage
# terms) or have too little space available.
# This script goes through all the mounted filesystems
# and checks each to see if the disk is nearly full,
# reporting only on those disks that warrant more attention.
# Set thresholds
min_free=4000
max_in_use=55
# Get a list of all file systems.
filesystems=`df -k | grep -v Use | grep -v none | awk '{ print $6 }'`
for filesystem in filesystem | tail -1`
# Split out the amount of space free as well as in-use percentage.
free=`echo entry | cut -d' ' -f5 | cut -d'%' -f1 `
# Check the file system percent in use.
if [ $(expr "max_in_use" ) ]
then
echo "free KB free at free < free < result != 0" ) ]
then
echo "free KB free."
fi
fi
done
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.