please help me in FreeBSD

Hi to all,

Iam doing a project in Free BSD and i am stuck with a puzzle. Please any one of you clarify my doubt :

How to add a mechanism to check the status of the file system which alerts the root user via. email if any single partition is greater than 90% full. This alert should include the file system directory name and the partition?
:confused:

Iam working on Free BSD 5.3 version. U all know that the output of 'df' command looks as follows:

Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/ad0s1a 253678 59116 174268 25% /
devfs 1 1 0 100% /dev
/dev/ad0s1e 253678 24280 209104 10% /tmp
/dev/ad0s1f 8913022 2615376 5584606 32% /usr
/dev/ad0s1d 253678 30246 203138 13% /var
devfs 1 1 0 100% /var/named/dev

Now i want to check which partition if greater than 90% full without scanning the first row of record. How to do this ? PLease anyone of u help me with this?

I'm not a regular BSD user, but this can be done in a shell script using "cut"

look up the man page for "cut" and you should immediately see how you can use it to parse the output of df

This is quick, done early in the morning, but it works. Please don't yell at my 'inefficiencies" ! :>D Streamline it as you will.
It more than likely NEEDS it BADLY.

#!/bin/ksh

get_size () {

IFS="%
"
df -k | grep '\/dev\/' | awk '{ printf "%s\t%d\n",$6,$5 }'

IFS="
"

}

alm_func () {
LIM=$1
shift
NUM=`echo $#/2 | bc`
while [ $NUM -gt 0 ]
doif [ $2 -gt $LIM ]; then

[INDENT]echo "Partition $1 is at $2'%'."
fi
shift;
shift;
((NUM=NUM-1))
done[/INDENT]
}

#=======

if [ $# -ne 1 ]; then
echo "$0: Invalid number of arguments"
echo "usage: $0 <filesystem utilization limit>"
exit 1
fi

LIMIT=$1

alm_func $LIMIT `get_size`

======
IFS is usually "<space><tab><\n>" I add the '%'
as a lazy way to make it a field delimiter and 'subtract' it from the 'df -k' output. Dirty, I know. :>D

==
If you want the DEVICE name, substitute '$1' for the '$6' in the AWK statement in "get_size()"

====