Google

自动数据库检查的脚本

2007-11-04 19:56 来源: codfei.cublog.cn 作者:codfei 网友评论 0 条 浏览次数 45
 
 
 
自动按照给定的数据库查询语句,来对oracle数据库进行查询,并发邮件报告,主要注意的是里面的环境变量的使用

#!/bin/bash

#20071031 Author by yupengfei

NOWTIME=`date '+%y-%m-%d-%H:%M:%S'`
DAY=`date +%m%d`
export LANG=C
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/9.2.0
export ORACLE_SID=jhf920b
export PATH=$ORACLE_HOME/bin:/bin:/opt/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/local/bin:/etc:/usr/openwin/bin:.
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib32
export LD_LIBRARY_PATH_64=$ORACLE_HOME/lib
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
su oracle -c "/opt/oracle/product/9.2.0/bin/sqlplus main/pass < /export/home/codfei/bin/oracle_check.sql" > /dev/null 2>&1
SMAIL()
{
MAIL_SUB="!** codfei: Report - Oracle Check Report **!"
mailx -s "$MAIL_SUB" codfei@hotmail.com << EOF
From :192.168.1.2
State :Report
ReportBy:/export/home/codfei/bin/oracle_check.sh
DateTime:$NOWTIME
Info :codfei/YuPengFei

                        Oracle Check Report

`cat /tmp/oracle_check.log`

EOF
}
line=`cat /tmp/oracle_check.log |sed -n '$='`
if [ "$line" -ne 21 ];
then
SMAIL
else
exit 1
fi

上一篇: 下一篇:

相关主题:数据库  脚本  检查

网友评论