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.
Oracle19c数据库OSWatcher.sh脚本详解:监控与数据管理

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

被折叠的 条评论
为什么被折叠?



