[shell] execute remote Script自動生成oracle awr report並mail出來
shell執行遠端Script自動生成awr report並mail出來
1.remote machine shell script
[mon@topaz source]$ more gen_oracle_awr
#!/bin/bash
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=wlcsp
AWRHOME=/home/mon/awr
#interval=8
#echo $ORACLE_SID
maxmin=`$ORACLE_HOME/bin/sqlplus -s /nolog << EOF # >> /home/mon/log/gen_oracle_awr.log #if general output to log,the maxmin will not get the value.
conn / as sysdba;
set heading off pagesize 0 feedback off verify off echo off;
select max(snap_id),min(snap_id) from dba_hist_snapshot where begin_interval_time>=sysdate-1 and begin_interval_time<=sysdate-1+8/24;
exit;
EOF`
#if [ -z "$maxmin" ]; then
# echo "no rows returned from database"
# exit 0
#else
# echo $maxmin
#fi
max=`echo $maxmin | awk '{print $1}'`
min=`echo $maxmin | awk '{print $2}'`
#echo $max
#echo $min
rm -rf $AWRHOME/*
$ORACLE_HOME/bin/sqlplus -s /nolog << EOF >> /dev/null
conn / as sysdba;
@?/rdbms/admin/awrrpt.sql;
html
2
$min
$max
$AWRHOME/awrrpt_1_${min}_${max}.html
EOF
#cat $AWRHOME/awrrpt_1_${min}_${max}.html | mutt -s "$ORACLE_SID Database AWR Report" -e "set content_type=text/html" tolilong@163.com -a $AWRHOME/awrrpt_1_${min}_${max}.html
2.local machine script
[mon@oracle6 source]$ more gen_remote_oracle_awr
#!/bin/bash
TAWRHOME=/home/mon/awr/topaz
ssh mon@topaz /home/mon/source/gen_oracle_awr
scp mon@topaz:/home/mon/awr/* $TAWRHOME/
FILE=`ls -tr $TAWRHOME/* | tail -1`
cat $FILE | mutt -s "Topaz Database AWR Report" -e "set content_type=text/html" tolilong@163.com -a $FILE
3.add crontab job
###############general remote awr################################
16 15 * * * /home/mon/source/gen_remote_oracle_awr > /dev/null 2>&1
1.remote machine shell script
[mon@topaz source]$ more gen_oracle_awr
#!/bin/bash
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=wlcsp
AWRHOME=/home/mon/awr
#interval=8
#echo $ORACLE_SID
maxmin=`$ORACLE_HOME/bin/sqlplus -s /nolog << EOF # >> /home/mon/log/gen_oracle_awr.log #if general output to log,the maxmin will not get the value.
conn / as sysdba;
set heading off pagesize 0 feedback off verify off echo off;
select max(snap_id),min(snap_id) from dba_hist_snapshot where begin_interval_time>=sysdate-1 and begin_interval_time<=sysdate-1+8/24;
exit;
EOF`
#if [ -z "$maxmin" ]; then
# echo "no rows returned from database"
# exit 0
#else
# echo $maxmin
#fi
max=`echo $maxmin | awk '{print $1}'`
min=`echo $maxmin | awk '{print $2}'`
#echo $max
#echo $min
rm -rf $AWRHOME/*
$ORACLE_HOME/bin/sqlplus -s /nolog << EOF >> /dev/null
conn / as sysdba;
@?/rdbms/admin/awrrpt.sql;
html
2
$min
$max
$AWRHOME/awrrpt_1_${min}_${max}.html
EOF
#cat $AWRHOME/awrrpt_1_${min}_${max}.html | mutt -s "$ORACLE_SID Database AWR Report" -e "set content_type=text/html" tolilong@163.com -a $AWRHOME/awrrpt_1_${min}_${max}.html
2.local machine script
[mon@oracle6 source]$ more gen_remote_oracle_awr
#!/bin/bash
TAWRHOME=/home/mon/awr/topaz
ssh mon@topaz /home/mon/source/gen_oracle_awr
scp mon@topaz:/home/mon/awr/* $TAWRHOME/
FILE=`ls -tr $TAWRHOME/* | tail -1`
cat $FILE | mutt -s "Topaz Database AWR Report" -e "set content_type=text/html" tolilong@163.com -a $FILE
3.add crontab job
###############general remote awr################################
16 15 * * * /home/mon/source/gen_remote_oracle_awr > /dev/null 2>&1
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2052133/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [Shell] 自動生成oracle awr report並mail出來OracleAI
- Script to generate AWR report from remote sql clientREMSQLclient
- awr 自動mailAI
- AWR Report 自動生成指令碼 [final]指令碼
- execute shell script from stored procedure
- shell指令碼實現自動生成awr報告指令碼
- 一個自動生成awr報告的shell指令碼指令碼
- 使用shell自動傳送Oracle AWR報告Oracle
- Shell Script(bash)--用於自動備份的Shell Script(轉)
- 自動生成AWR報告並以郵件附件傳送
- 自動生成AWR HTML報告HTML
- 【AWR】自動生成AWR報告指令碼以及用法指令碼
- 自動啟動ORACLE Script ServiceOracle
- 定時自動生成awr報告
- AWR報告自動生成指令碼指令碼
- 自動生成awr報告指令碼指令碼
- Oracle10g 自動生成AWR報告的指令碼Oracle指令碼
- awr報告每天自動生成指令碼指令碼
- AWR不能自動生成快照解決方法?
- Oracle10g自動生成AWR分析報告的指令碼Oracle指令碼
- Oracle 10g AWR Report 分析(轉)Oracle 10g
- Linux程式設計-11.Shell Script(bash)--(3)用於自動備份的Shell Script(轉)Linux程式設計
- Oracle生成awr報告Oracle
- Oracle 生成awr報告Oracle
- AWR 及STATSPACK的snapshot不能自動生成排查
- 【AWR】Oracle批量生成awr報告指令碼Oracle指令碼
- AWR Execute to Parse引數解析
- Shell Script
- shell script
- 使用shell生成orabbix自動化配置指令碼指令碼
- Oracle 客戶端生成AWR方法Oracle客戶端
- Shell Script(轉)
- [Linux] mutt mail oracle awr [Html能正常顯示錶格]LinuxAIOracleHTML
- 【Oracle】並行等待之PX Deq: Execute ReplyOracle並行
- ORACLE自動備份shell指令碼Oracle指令碼
- Jenkins上實現Python + Jenkins + Allure Report 介面自動化測試持續整合,並生成allure-report測試報告JenkinsPython測試報告
- ORACLE 11G生成AWR報告Oracle
- awr自動收集指令碼指令碼