Wednesday, October 21, 2009

Script to monitor a Filesystem on AIX

#!/bin/sh

# This script checks if the /siebel filesystem reaches 2 GB of free space
# And then delete the old logs except those of today

warninglimit=2097152    # This number is in KB, it's equal to 2 GB,
                        # KB is used to avoid floating point numbers

filesystems="/siebel"   # List of filesystems to be monitored, separated by
                        # blank spaces

for fs in $filesystems  # Loop on the list of filesystems above
do
        size=`df -k $fs|grep $fs|awk '{ print $3; }'`   # Extract size of
                                                        # Filesystem in KB
        if [ $size -le $warninglimit ]  # If fs size is less than warning lim.
        then
                echo "WARNING: Low disk space for $fs ($size)"
                # Add what to delete here
        fi
done

1 comment:

Mohammed Hewedy said...

very handy script, thanks.