###############################################
# deadlock_alert.sh
###############################################
#!/bin/ksh
. /etc/oracle.profile
sqlplus -s <<!oracle/$1@‚$2
set feed off
set heading off
spool deadlock.alert
SELECT SID, DECODE(BLOCK, 0, 'NO', 'YES' ) BLOCKER,
DECODE(REQUEST, 0, 'NO','YES' ) WAITER
FROM V$LOCK
WHERE REQUEST > 0 OR BLOCK > 0
ORDER BY block DESC;
spool off
exit
!
if [ `cat deadlock.alert|wc -l` -gt 0 ]
then
mailx -s "DEADLOCK ALERT for ${2}" meinDBA@meineFirma.de < deadlock.alert
fi
