home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!van-bc!twg!bill
- From: bill@twg.bc.ca (Bill Irwin)
- Newsgroups: comp.unix.admin
- Subject: Re: does anyone have a disk x% full capture program???
- Message-ID: <2790@twg.bc.ca>
- Date: 16 Nov 92 06:03:37 GMT
- References: <fish.721343514@news2.gsfc.nasa.gov>
- Reply-To: bill@twg.bc.ca (Bill Irwin)
- Organization: The Westrheim Group, Vancouver, B.C., Canada
- Lines: 69
-
- fish@daacdev1.stx.com writes:
-
- : i'm just looking for something that would occasionally run and
- : see if a disk was more than say 90% full it would notify me
- : instead of waiting for the 100% full kernel warnings.
-
- : thanx,
- : fish
-
- This is a shell script I whipped up one day when I got surprised
- about a filesystem running out of space.
-
- ----------------- snip 8< 8< 8< snip ------------
- Used=99 # Percent of file system used for warning.
- Blocks=5000 # Minimum free blocks
- Warning=no
- [ $# -gt 0 ] && MailTo=$1
- for Sizes in `df -v | grep -v Filesystem|awk '{print $6}'`
- do
- if [ $Sizes -gt $Used ]
- then Print=yes
- fi
- done
- for Sizes in `df -v | grep -v Filesystem|awk '{print $5}'`
- do
- if [ $Sizes -lt $Blocks ]
- then Print=yes
- fi
- done
- if [ ${Print=no} = yes ]
- then
- case $MailTo in
- [A-z0-9]*)
- TempFile=/tmp/dl.$$
- echo "File System % Used" >$TempFile
- echo "----------- ------ ---------Free Space--------\n"\
- >>$TempFile
- df -v | grep -v Filesystem | \
- awk '{
- if( $6 > '$Used' || '$Blocks' > $5 )
- printf( "%-10s\t\t%s\t%6d blocks %3d.%1d Mbytes\n", \
- $2, $6, $5, $5 * 512 / 1000000, $5 * 512 % 1000000 / 100000 )\
- }' >> $TempFile
- mail -s "*** WARNING *** Disk Low" $MailTo <$TempFile
- rm $TempFile
- ;;
- *)
- echo "File System % Used"
- echo "----------- ------ ---------Free Space--------\n"
- df -v | grep -v Filesystem | \
- awk '{
- if( $6 > '$Used' || '$Blocks' > $5 )
- printf( "%-10s\t\t%s\t%6d blocks %3d.%1d Mbytes\n", \
- $2, $6, $5, $5 * 512 / 1000000, $5 * 512 % 1000000 / 100000 )\
- }'
- ;;
- esac
- else
- echo "\nNo filesystems are low on space."
- fi
-
- ----------------- snip 8< 8< 8< snip ------------
-
- Hope this helps.
- --
- Bill Irwin - The Westrheim Group - Vancouver, BC, Canada
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- uunet!twg!bill (604) 431-9600 (voice) | Your Computer
- bill@twg.bc.ca (604) 430-4329 (fax) | Systems Partner
-