Cover V05, I10
Article
Listing 1
Listing 10
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7
Listing 8
Listing 9

oct96.tar


Listing 6: diskspace.sh

:
#######################################################
# diskspace.sh
#######################################################
# diskspace.sh - if disk space amounts change by a
# predetermined amount (as specified in the out file),
# then echo the change.  The output from the script goes
# to a pseudo file.

# make sure this is being run by a posix compliant shell
test "$((1))" = 1 || exec ksh $0 "$@"

ctrldir=/u/stevei/fchange
: ${datafile:=$ctrldir/pseudo/diskspace.out}

test -f $datafile || {
echo "Error: could not find: $datafile"
exit 1
}

awk '/^(#| |$)/ {
# if not a data line, then prepend # #
print "# #", $0
next
}
{print}' $datafile |
while read dir cursize delta
do
# if # # was sent, just echo the line and continue
case "$dir" in
\#) echo "$delta"; continue ;;
esac

# determine new size
newsize=$(bdf $dir | awk '/[0-9]%/{
size=$(NF - 1)
sub(/%/,"",size)
print size
}')

if test $(( $cursize - $newsize )) -ge $delta -o \
$(( $newsize - $cursize )) -ge $delta
then
cursize=$newsize
fi
echo "$dir $cursize $delta"
done

exit 0


# This is the diskspace.sh data file
# format is:
#  [directory] [current % full] [size in change to report]

/product/source 86 10
/product/tools 80 5
/product/sccs 73 5
/usr 90 3