#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 SID"
exit 1
fi
# source oracle OS variables
. /var/opt/oracle/oraset $1
#
BOX=`uname -a | awk '{print$2}'`
#
sqlplus -s <<EOF
/ as sysdba
spo $HOME/bin/log/statspackdelta.txt
set lines 80
set pages 100
SELECT s1.snap_time,
w1.event,
s1.snap_id,
ROUND((w1.time_waited_micro/1000000/total_waits),4) "Avg_wait_sec",
LAG(ROUND((w1.time_waited_micro/1000000/total_waits),4))
OVER (ORDER BY ROUND((w1.time_waited_micro/1000000/total_waits),4)) prev_value,
ROUND((w1.time_waited_micro/1000000/total_waits),4) - LAG(ROUND((w1.time_waited_micro/1000000/total_waits),4))
OVER (ORDER BY ROUND((w1.time_waited_micro/1000000/total_waits),4)) delta_value
FROM stats\$snapshot s1,
stats\$system_event w1
WHERE s1.snap_id between (SELECT MIN(snap_id) FROM stats\$snapshot WHERE snap_time>=TRUNC(sysdate-1)+5/1440)
AND (SELECT MIN(snap_id) FROM stats\$snapshot WHERE snap_time>TRUNC(sysdate)+5/1440)
AND s1.snap_id = w1.snap_id
ORDER BY 1 desc,4 desc,6 desc;
EOF
cat $HOME/bin/log/statspackdelta.txt | mailx -s "Statspack wait event delta report on DB: $1 $BOX" u.inal@xxx.com
exit 0
Ardından crontab içine günlük rütin çalışması için eklenir.
# Wait event delta degisim rapor
16 11 * * * /orahome/oracle/bin/statspackdelta.bsh DBA1
16 11 * * * /orahome/oracle/bin/statspackdelta.bsh DBA1
0 yorum:
Yorum Gönder