#!/bin/bash

#asmfreespacecheck.sh (c) Tim Onions 2007
# Please check this script works as expected on a test system before using on a production database.
# The author can accept no liability or responsibility for any ill-effect it may have.
# You are free to use this script on one condition - use it to improve the performance of your database!

echo $1=lower limit of freespace below which we need to raise and alert
echo $2=list of email addresses to send alert to (delimited)

echo may need to cd to the location of your scripts here...
$ORACLE_HOME/bin/sqlplus -s -l /nolog <<EOF |awk '(NF>8&&$9=="ERROR") {print "\"",$1,$8,$9,"\""}'|xargs -rt -l1 mail $2 -s
connect / AS SYSDBA
@asmfreespace.sql $1
exit
EOF