ADSM-L

Re: SCRIPT FOR df -k ALERTS ATTACHED

2002-09-12 09:00:10
Subject: Re: SCRIPT FOR df -k ALERTS ATTACHED
From: David Stabler <dstabler AT MORRISONHOMES DOT COM>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Thu, 12 Sep 2002 08:44:47 -0400
> praveenkumark AT VYSBANK DOT COM wrote on 09/12/02 02:58AM
> .if someone can help me in completing this task using a single
> script it would be helpful....

How about....... (assuming you have /bin/ksh)

#!/bin/sh
#
# this program scans the filesystems for ones that exceed a maximum
# percentage used.  The parameter is set inline, but could be called
# as a passed parameter, but the command below would need to be
# changed to MAXPCT=${1}
#
# set MAXPCT to size to watch for
#
MAXPCT=80
#
# run df command, remove line starting with "Filesys..." as it isn't a
filesystem but
# a header.  Read the input values for reuse in output commands in a
loop that
# runs until we are out of filesystems to scan.
#
# ASSUMPTION: output of df-k command looks like this:
# /dev/lvname  blocksize  freeblocks   pctused  inodes_used
pctinodes_used mountpoint
#
#
df -k | grep -v "^Filesys" | \
   while read lvol size free pctu iused piused filesys
   do
#
# in order to strip off the %, make it  the 'input field seperator',
which means
# that the first value will be the actual number.  Using a variable
inline like this
# only sets it for the program running, so the IFS is only temporarily
set to %
# and only for the read process...
#
     echo ${pctu} | IFS=% read pctval etc
#
# test to see if too big....
#
     if [ ${pctval} -gt ${MAXPCT} ]; then
        echo "${filesys} exceeds ${MAXPCT}% used (${pctval})"
#
# additional information could be printed, like the logical volume
information,
# free space, etc....but, we won't do it just  yet.  Later revision,
maybe.
#
     fi
   done
exit 0

David Stabler, CATE/AIX, CNCE
Senior Systems Analyst

<Prev in Thread] Current Thread [Next in Thread>