OSWatcher.sh脚本说明

Oracle19c数据库OSWatcher.sh脚本详解:监控与数据管理
OSWatcher.sh是一个用于监控Oracle19c数据库的脚本,由startOSWbb.sh和stopOSWbb.sh控制启动和停止。该脚本按指定的快照间隔收集系统数据,如iostat、vmstat等,并可配置压缩工具和归档目录。OSWatcherFM.sh辅助脚本负责管理归档数据,删除超出保留期限的文件。用户可以通过extras.txt自定义额外的采集命令。采集到的数据可用于生成分析报告,帮助诊断系统性能问题。

OSWatcher.sh脚本位于oswbb目录下(Oracle 19c数据库中脚本的路径是:
/u01/app/oracle/product/19.0.0/dbhome_1/suptools/tfa/release/tfa_home/ext/oswbb/),由脚本startOSWbb.sh和stopOSWbb.sh来调用启动和停止它。

1. startOSWbb.sh脚本和stopOSWbb.sh脚本

startOSWbb.sh脚本有4个参数,如下所示:

# $1 = snapshot interval in seconds.
# $2 = the number of hours of archive data to store.
# $3 = (optional) the name of the zip or compress utility you want
#      OSWbb to use to zip up the archive files upon completion. If
#      no zipping is desired set this parameter = NONE. This will
#      allow for the $4 parameter below to be recognized as both $3 
#      and $4 are optional parameters.
# $4 = (optional) the fully qualified name of the archive directory
#      where you want oswbb to save your data. This option can be used
#      instead of setting the UNIX environment variable OSWBB_ARCHIVE_DEST
#      If this parameter is not set oswbb will look for the UNIX
#      environment variable OSWBB_ARCHIVE_DEST. If neither are set
#      the archive directory will remain in the default location under
#      the oswbb directory

./OSWatcher.sh $1 $2 $3 $4 &

第1个参数$1指定快照的时间间隔,即每隔$1秒就采样一次数据,默认值是30秒
第2个参数$2指定保存的每小时的归档数据的数量,即只保存最近的$2小时的数据,默认是48小时
第3个参数$3指定用来压缩归档文件的工具名称
第4个参数$4指定存储数据的归档目录,也可以直接设置OSWBB_ARCHIVE_DEST环境变量来指定该目录,默认是当前目录下的archive目录

如下示例每隔60秒采样一次数据,只保存最近24小时的采样数据,使用gzip对每小时采集的数据进行压缩,数据存放在/u01/dump/archive目录下:
./startOSWbb.sh 60 24 gzip /u01/dump/archive

停止OSWatcher的脚本:
./stopOSWbb.sh


2. 文件管理脚本OSWatcherFM.sh

脚本OSWatcher.sh启动时,会调用文件清理脚本OSWatcherFM.sh在后台对采集的每小时的数据文件进行管理。

./OSWatcherFM.sh $archiveInterval $OSWBB_ARCHIVE_DEST &

OSWatcherFM.sh脚本每分钟扫描一次收集的数据文件的数量,删除超过startOSWbb.sh脚本参数$3指定时间(默认48小时)的数据。

numberOfFiles=`ls -t $2/oswtop | wc -l`
numberToDelete=`expr $numberOfFiles - $archiveInterval`
if [ $numberOfFiles -gt $archiveInterval ]
  then
    ls -t $2/oswtop/* | tail -$numberToDelete | xargs rm
fi

3. OSWatcher.sh脚本

OSWatcher.sh脚本每隔startOSWbb.sh脚本参数$1指定的快照时间间隔执行一次采样数据的命令,如下所示:

until test 0 -eq 1
do
echo "oswbb heartbeat:"`date`
 hour=`date +'%y.%m.%d.%H00.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值