sysstatgar.sh 收集資料庫指標資訊指令碼
#!/bin/sh
#
# sysstatgar.sh, Gather system v$sysstat details .
# sh sysstatgar.sh SERVICE_IP
if [ $# -ne 1 ]; then
echo "Usage: sh sysstatgar.sh SERVICE_IP"
exit 1;
fi
BASE_HOME=`/usr/bin/dirname "$0"`
. ~/.profile
# Log To LogFile
MLOGFILE=${BASE_HOME}/`hostname`_sysstat_`date +%Y%m`.log
BEFOREVALUE=${BASE_HOME}/before_value.file
KPIFILE=${BASE_HOME}/kpi_key.value
exec >> ${MLOGFILE} 2>&1
echo "Current time " `date +%Y%m%d%H%M%S`
IPADDR=$1
# Get Instance name
INSTNAME=`sqlplus -S '/ as sysdba' << EO
set pages 0 heading off verify off feedback off echo off
SELECT instance_name FROM v\\\$instance;
EO`
ftp_upload_()
{
TEMP="$1|$2|$3|`date +%Y%m%d%H%M%S`"
TMPFILE="`hostname`_oracle_`date +%Y%m%d%H%M%S`.tok"
echo ${TEMP} > /tmp/${TMPFILE}
ftp -n << EOD
open 10.19.251.64
user aiox zwzx%1208B
prompt off
bin
cd /home/aiox/busicollect/oracle_coll/source
lcd /tmp
put ${TMPFILE}
close
bye
EOD
rm -f /tmp/${TMPFILE}
}
if [ ! -s ${KPIFILE} ]; then
echo "SDBB_01 user_commits " >> ${KPIFILE}
echo "SDBB_02 user_rollbacks " >> ${KPIFILE}
echo "SDBB_03 user_calls " >> ${KPIFILE}
echo "SDBB_04 session_logical_reads " >> ${KPIFILE}
echo "SDBB_05 CPU_used_by_this_session " >> ${KPIFILE}
echo "SDBB_06 DB_time " >> ${KPIFILE}
echo "SDBB_07 session_pga_memory_max " >> ${KPIFILE}
echo "SDBB_08 enqueue_waits " >> ${KPIFILE}
echo "SDBB_09 consistent_gets " >> ${KPIFILE}
echo "SDBB_10 physical_reads " >> ${KPIFILE}
echo "SDBB_11 physical_writes " >> ${KPIFILE}
echo "SDBB_12 redo_size " >> ${KPIFILE}
echo "SDBB_13 undo_change_vector_size " >> ${KPIFILE}
echo "SDBB_14 transaction_rollbacks " >> ${KPIFILE}
echo "SDBB_15 table_scans_(long_tables) " >> ${KPIFILE}
echo "SDBB_16 parse_count_(total) " >> ${KPIFILE}
echo "SDBB_17 parse_count_(hard) " >> ${KPIFILE}
echo "SDBB_18 execute_count " >> ${KPIFILE}
echo "SDBB_19 sorts_(memory) " >> ${KPIFILE}
echo "SDBB_20 sorts_(disk) " >> ${KPIFILE}
fi
BCNT=`cat ${BEFOREVALUE}|wc -l`
echo "ORACLE DATABASE SYSSTAT GATHER BEGIN......................................"
TEMPFILE="${BASE_HOME}/systat_gar_`date +%Y%m%d%H%M%S`.log"
sqlplus -S '/ as sysdba' << EOF
set line 330
col name for a30
set pages 0 heading off verify off feedback off echo off
col value for 9999999999999999999999999
spool ${TEMPFILE}
SELECT a.statistic#,replace(b.name,' ','_'),a.value value FROM v\$sysstat a,v\$statname b
WHERE a.statistic# = b.statistic#
AND replace(b.name,' ','_') IN ('user_commits','user_rollbacks','user_calls','session_logical_reads','CPU_used_by_this_session','DB_time','session_pga_memory_max','enq
ueue_waits','consistent_gets','physical_reads','physical_writes','redo_size','undo_change_vector_size','transaction_rollbacks','table_scans_(long_tables)','parse_count
_(total)','parse_count_(hard)','execute_count','sorts_(memory)','sorts_(disk)');
spool off;
exit;
EOF
if [ ${BCNT} -gt 4 ]; then
while read line
do
statname=`echo ${line}|awk '{print $2}'`
LASTVAL=`cat ${BEFOREVALUE}|grep ${statname}|awk '{print $3}'`
CURVAL=`echo ${line}|awk '{print $3}'`
DIFFVAL=`expr ${CURVAL} - ${LASTVAL}`
KPI=`cat ${KPIFILE}|grep ${statname}|awk '{print $1}'`
ftp_upload_ $IPADDR"*oracle*"${INSTNAME} ${KPI} ${DIFFVAL}
sleep 2
done < ${TEMPFILE}
fi
cat ${TEMPFILE} > ${BEFOREVALUE}
rm -f ${TEMPFILE}
echo "ORACLE DATABASE SYSSTAT GATHER END......................................"
#
# sysstatgar.sh, Gather system v$sysstat details .
# sh sysstatgar.sh SERVICE_IP
if [ $# -ne 1 ]; then
echo "Usage: sh sysstatgar.sh SERVICE_IP"
exit 1;
fi
BASE_HOME=`/usr/bin/dirname "$0"`
. ~/.profile
# Log To LogFile
MLOGFILE=${BASE_HOME}/`hostname`_sysstat_`date +%Y%m`.log
BEFOREVALUE=${BASE_HOME}/before_value.file
KPIFILE=${BASE_HOME}/kpi_key.value
exec >> ${MLOGFILE} 2>&1
echo "Current time " `date +%Y%m%d%H%M%S`
IPADDR=$1
# Get Instance name
INSTNAME=`sqlplus -S '/ as sysdba' << EO
set pages 0 heading off verify off feedback off echo off
SELECT instance_name FROM v\\\$instance;
EO`
ftp_upload_()
{
TEMP="$1|$2|$3|`date +%Y%m%d%H%M%S`"
TMPFILE="`hostname`_oracle_`date +%Y%m%d%H%M%S`.tok"
echo ${TEMP} > /tmp/${TMPFILE}
ftp -n << EOD
open 10.19.251.64
user aiox zwzx%1208B
prompt off
bin
cd /home/aiox/busicollect/oracle_coll/source
lcd /tmp
put ${TMPFILE}
close
bye
EOD
rm -f /tmp/${TMPFILE}
}
if [ ! -s ${KPIFILE} ]; then
echo "SDBB_01 user_commits " >> ${KPIFILE}
echo "SDBB_02 user_rollbacks " >> ${KPIFILE}
echo "SDBB_03 user_calls " >> ${KPIFILE}
echo "SDBB_04 session_logical_reads " >> ${KPIFILE}
echo "SDBB_05 CPU_used_by_this_session " >> ${KPIFILE}
echo "SDBB_06 DB_time " >> ${KPIFILE}
echo "SDBB_07 session_pga_memory_max " >> ${KPIFILE}
echo "SDBB_08 enqueue_waits " >> ${KPIFILE}
echo "SDBB_09 consistent_gets " >> ${KPIFILE}
echo "SDBB_10 physical_reads " >> ${KPIFILE}
echo "SDBB_11 physical_writes " >> ${KPIFILE}
echo "SDBB_12 redo_size " >> ${KPIFILE}
echo "SDBB_13 undo_change_vector_size " >> ${KPIFILE}
echo "SDBB_14 transaction_rollbacks " >> ${KPIFILE}
echo "SDBB_15 table_scans_(long_tables) " >> ${KPIFILE}
echo "SDBB_16 parse_count_(total) " >> ${KPIFILE}
echo "SDBB_17 parse_count_(hard) " >> ${KPIFILE}
echo "SDBB_18 execute_count " >> ${KPIFILE}
echo "SDBB_19 sorts_(memory) " >> ${KPIFILE}
echo "SDBB_20 sorts_(disk) " >> ${KPIFILE}
fi
BCNT=`cat ${BEFOREVALUE}|wc -l`
echo "ORACLE DATABASE SYSSTAT GATHER BEGIN......................................"
TEMPFILE="${BASE_HOME}/systat_gar_`date +%Y%m%d%H%M%S`.log"
sqlplus -S '/ as sysdba' << EOF
set line 330
col name for a30
set pages 0 heading off verify off feedback off echo off
col value for 9999999999999999999999999
spool ${TEMPFILE}
SELECT a.statistic#,replace(b.name,' ','_'),a.value value FROM v\$sysstat a,v\$statname b
WHERE a.statistic# = b.statistic#
AND replace(b.name,' ','_') IN ('user_commits','user_rollbacks','user_calls','session_logical_reads','CPU_used_by_this_session','DB_time','session_pga_memory_max','enq
ueue_waits','consistent_gets','physical_reads','physical_writes','redo_size','undo_change_vector_size','transaction_rollbacks','table_scans_(long_tables)','parse_count
_(total)','parse_count_(hard)','execute_count','sorts_(memory)','sorts_(disk)');
spool off;
exit;
EOF
if [ ${BCNT} -gt 4 ]; then
while read line
do
statname=`echo ${line}|awk '{print $2}'`
LASTVAL=`cat ${BEFOREVALUE}|grep ${statname}|awk '{print $3}'`
CURVAL=`echo ${line}|awk '{print $3}'`
DIFFVAL=`expr ${CURVAL} - ${LASTVAL}`
KPI=`cat ${KPIFILE}|grep ${statname}|awk '{print $1}'`
ftp_upload_ $IPADDR"*oracle*"${INSTNAME} ${KPI} ${DIFFVAL}
sleep 2
done < ${TEMPFILE}
fi
cat ${TEMPFILE} > ${BEFOREVALUE}
rm -f ${TEMPFILE}
echo "ORACLE DATABASE SYSSTAT GATHER END......................................"
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29446986/viewspace-1874424/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【SCRIPT】Oracle資料庫基本資訊收集指令碼Oracle資料庫指令碼
- 收集資料庫統計資訊需要收集直方圖資訊.資料庫直方圖
- 【TABLE】Oracle表資訊收集指令碼Oracle指令碼
- 6 收集資料庫統計資訊資料庫
- MySQL對所有表收集統計資訊(Python 2指令碼)MySqlPython指令碼
- Oracle運維指令碼-收集統計資訊Oracle運維指令碼
- 【SQL】Oracle資料庫資料量及效能資訊收集SQLOracle資料庫
- Script:收集資料庫安全風險評估資訊資料庫
- 收集資料庫升級/遷移診斷資訊的指令碼 (dbupgdiag.sql) (文件 ID 1577288.1)資料庫指令碼SQL
- Oracle 11g 統計資訊收集指令碼Oracle指令碼
- 通過shell指令碼得到資料庫的基本資訊(一)指令碼資料庫
- 不能連線資料庫收集Systemstate Dumps資訊資料庫
- faker 資料填充常用指令收集
- 系統日誌及資料庫相關資訊收集資料庫
- 資料庫備份指令碼資料庫指令碼
- 刪除資料庫指令碼資料庫指令碼
- 資料庫監控指令碼資料庫指令碼
- 資料庫全備指令碼資料庫指令碼
- 監控資料庫指令碼資料庫指令碼
- Oracle 判斷 並 手動收集 統計資訊 指令碼Oracle指令碼
- 指向常量資料的指標和常量指標指標
- 呼叫中心資料入庫指令碼指令碼
- 資料庫批次授權指令碼資料庫指令碼
- Sybase 資料庫啟停指令碼資料庫指令碼
- [zt]資料庫監控指令碼資料庫指令碼
- 資料庫全備份指令碼資料庫指令碼
- 資料庫監控指令碼(一)資料庫指令碼
- 資料庫監控指令碼(二)資料庫指令碼
- 資料庫監控指令碼(三)資料庫指令碼
- 指令碼建立Oracle的資料庫指令碼Oracle資料庫
- 批次起停資料庫指令碼資料庫指令碼
- MySQL匯出資料庫指令碼MySql資料庫指令碼
- Sentry 企業級資料安全解決方案 - Relay 監控 & 指標收集指標
- 收藏!生物資訊學資料庫大全,全網最全收集整理!資料庫
- 如何收集 NGINX 指標(第二篇)Nginx指標
- 透過shell指令碼得到資料字典的資訊指令碼
- 通過shell指令碼得到資料字典的資訊指令碼
- 導庫標準引數指令碼指令碼