---snip---
#!/bin/sh
if [ "x$2" == "x" ] ; then
echo "usage: $0"
echo "example: $0 \"^/dev/sda\" 50"
exit 1
fi
OLD_IFS=$IFS
IFS=$'\n'
for i in $(df -h|grep "$1"|grep -v boot|sed -e "s/ */ /g"|cut -d ' ' -f 1,4,6)
do
DEVICE=$(echo $i|cut -d ' ' -f 1)
SPACE=$(echo $i|cut -d ' ' -f 2)
MOUNTPOINT=$(echo $i|cut -d ' ' -f 3)
if [ "G" == ${SPACE:$(expr ${#SPACE} - 1):$( expr ${#SPACE} - 1)} ] ; then
#there are gigabytes free...
continue
fi
j=${SPACE:0:$(expr ${#SPACE} - 1)} #2>/dev/null
if [ $? != 0 ] ; then
echo "usage: $0"
echo "example: $0 "^/dev/sda" 50"
exit 1
fi
if [ $2 -ge $j ] ; then
echo "WARNING: disk full on $HOST! just $j MB left on device $DEVICE mounted to $MOUNTPOINT!"
fi
done
IFS=$OLD_IFS
---snap---
Example:
bash~> diskfull.sh "^/dev/hda" 100
No comments:
Post a Comment