OSWatcher Black Box, 简称OSW,是oracle提供的一个小但是非常有用的工具,它通过调用OS自己提供的命令来记录OS运行时的一些性能参数,比如CPU/Memory/Swap/Network IO/Disk IO相关的信息。
但是部署OSW有很多好处:
1. 它比较容易部署,并且容易删除。
2. 资源消耗比较小,不管是从CPU,内存还是磁盘空间来说。
3. 平时不需要维护,并且在发生问题时可以帮我们迅速定位问题是否发生在OS端
数据库是运行在OS之上的,如果OS发生了异常,那么数据库肯定也会受到影响;如果我们仅仅从数据库的角度去分析这样的问题时,很难有个好结果.
官方博客介绍如下:
https://blogs.oracle.com/Database4CN/entry/%E5%88%A9%E5%99%A8osw_oswatcher_black_box_%E4%B9%8B%E7%AE%80%E4%BB%8B%E7%AF%87
1、下载
从MOS上里的文档301137.1上下载OSW,需要有MOS账号
百度网盘:http://pan.baidu.com/s/1bYdzJ4
2、安装
随便找一个目录解压安装,不要在/tmp目录,不必须root用户
[oracle@rhel6 ~]$ mkdir oswatcher [oracle@rhel6 ~]$ mv oswbb734.tar oswatcher/ [oracle@rhel6 ~]$ cd oswatcher/ [oracle@rhel6 oswatcher]$ ls oswbb734.tar [oracle@rhel6 oswatcher]$ tar -xvf oswbb734.tar oswbb/ oswbb/call_uptime.sh oswbb/profile/ oswbb/analysis/ oswbb/tar_up_partial_archive.sh oswbb/oswsub.sh oswbb/oswrds.sh oswbb/src/ oswbb/src/missing_graphic.gif oswbb/src/tombody.gif oswbb/src/coe_logo.gif oswbb/src/Thumbs.db oswbb/src/OSW_profile.htm oswbb/src/oswbba_input.txt oswbb/src/watch.gif oswbb/oswib.sh oswbb/call_du.sh oswbb/tarupfiles.sh oswbb/ltop.sh oswbb/nfssub.sh oswbb/docs/ oswbb/docs/OSWatcher/ oswbb/docs/OSWatcher/OSWatcherUserGuide.pdf oswbb/docs/OSWatcher/oswbb_README.txt oswbb/docs/The_Analyzer/ oswbb/docs/The_Analyzer/oswbba_README.txt oswbb/docs/The_Analyzer/oswbbaUserGuide.pdf oswbb/docs/The_Analyzer/OSWatcherAnalyzerOverview.pdf oswbb/OSWatcher.sh oswbb/psmemsub.sh oswbb/call_sar.sh oswbb/oswnet.sh oswbb/Exampleprivate.net oswbb/mpsub.sh oswbb/Example_extras.txt oswbb/OSWatcherFM.sh oswbb/startOSWbb.sh oswbb/ifconfigsub.sh oswbb/iosub.sh oswbb/oswbba.jar oswbb/vmsub.sh oswbb/xtop.sh oswbb/stopOSWbb.sh
OSWatcher包含两部分:
oswbb:这是一个shell脚本,用于收集和存储数据
oswbba:这是一个java工具用于分析收集到的数据并提供建议,还可以生成图片或html文档。
3、启动OSWatcher
startOSWbb.sh脚本有四个参数:
ARG1 = snapshot interval in seconds.
ARG2 = the number of hours of archive data to store.
ARG3 = (optional) the name of a compress utility to compress each file automatically after it is created.
ARG4 = (optional) an alternate (non default) location to store the archive directory.
如果不输入任何参数,默认间隔30秒收集一次数据,并且默认保存48小时的数据。
默认收集到的数据会存储在解压目录下的archive目录下,这个目录是在第一次启动startOSWbb.sh脚本时创建的。
#启动startOSWbb.sh脚本,间隔15秒,保存5天的数据 [oracle@rhel6 oswbb]$ nohup sh startOSWbb.sh 15 120 & [1] 3131 [oracle@rhel6 oswbb]$ nohup: ignoring input and appending output to `nohup.out' [1]+ Done nohup sh startOSWbb.sh 15 120 #查看输出日志 [oracle@rhel6 oswbb]$ more nohup.out Setting the archive log directory to/home/oracle/oswatcher/oswbb/archive Testing for discovery of OS Utilities... VMSTAT found on your system. IOSTAT found on your system. MPSTAT found on your system. IFCONFIG found on your system. NETSTAT found on your system. TOP found on your system. Testing for discovery of OS CPU COUNT oswbb is looking for the CPU COUNT on your system CPU COUNT will be used by oswbba to automatically look for cpu problems CPU COUNT found on your system. CPU COUNT = 2 Discovery completed. #生成的archive目录下生成了对应不同收集信息的目录 [oracle@rhel6 oswbb]$ cd archive [oracle@rhel6 archive]$ ls oswifconfig oswiostat oswmeminfo oswmpstat oswnetstat oswprvtnet oswps oswslabinfo oswtop oswvmstat
MOS文档 ID 1531223.1有详细的介绍各个目录的含义。
在OSWbb第一次使用时,它会创建一些归档的子目录。 这些归档目录包含7个子目录,每一个子目录对应一个收集数据。 这7个目录分别对应:top, vmstat, iostat, mpstat, netstat, ps 和一个可选的traceprivate network。
要启动private network,必须先在oswbb目录下创建一个private.net的可执行文件。 这个文件里的内容可以是用来验证RAC private network的traceroute命令,不同平台使用traceroute命令的参数不尽相同,private.net文件可以可以根据Exampleprivate.net文件来修改创建。
HP-UX的一个例子
###################################################################### #HP Example ###################################################################### echo "zzz ***"`date` traceroute -r -F 192.168.2.21 traceroute -r -F 192.168.2.22 ###################################################################### # DO NOT DELETE THE FOLLOWING LINE!!!!!!!!!!!!!!!!!!!!! ###################################################################### rm locks/lock.file
4、分析OSWatcher收集到的日志
使用oswbba.jar包进行日志的分析,但是jara要在1.4.2及以上版本。
两种方法分析数据
1)生成图形
[oracle@rhel6 oswbb]$ export DISPLAY=192.168.56.1:0.0 [oracle@rhel6 oswbb]$ java -jar oswbba.jar -i archive Starting OSW Analyzer V7.3.3 OSWatcher Analyzer Written by Oracle Center of Expertise Copyright (c) 2014 by Oracle Corporation Parsing Data. Please Wait... Scanning file headers for version and platform info... Parsing file rhel6_iostat_16.12.19.1100.dat ... Parsing file rhel6_vmstat_16.12.19.1100.dat ... Parsing file rhel6_netstat_16.12.19.1100.dat ... Parsing file rhel6_top_16.12.19.1100.dat ... Parsing file rhel6_ps_16.12.19.1100.dat ... Parsing Completed. Enter 1 to Display CPU Process Queue Graphs Enter 2 to Display CPU Utilization Graphs Enter 3 to Display CPU Other Graphs Enter 4 to Display Memory Graphs Enter 5 to Display Disk IO Graphs Enter 6 to Generate All CPU Gif Files Enter 7 to Generate All Memory Gif Files Enter 8 to Generate All Disk Gif Files Enter L to Specify Alternate Location of Gif Directory Enter T to Alter Graph Time Scale Only (Does not change analysis dataset) Enter D to Return to Default Graph Time Scale Enter R to Remove Currently Displayed Graphs Enter A to Analyze Data Enter S to Analyze Subset of Data(Changes analysis dataset including graph time scale) Enter P to Generate A Profile Enter X to Export Parsed Data to File Enter Q to Quit Program Please Select an Option:7 Generating file gif/Dec19110157_1482117313/OSWg_OS_Memory_Swap.gif Generating file gif/Dec19110157_1482117313/OSWg_OS_Memory_Free.gif Generating file gif/Dec19110157_1482117313/OSWg_OS_Memory_Page_In_Rate.gif
2)生成报告
[oracle@rhel6 oswbb]$ java -jar oswbba.jar -i archive -A Scanning file headers for version and platform info... Parsing file rhel6_iostat_16.12.19.1100.dat ... Parsing file rhel6_vmstat_16.12.19.1100.dat ... Parsing file rhel6_netstat_16.12.19.1100.dat ... Parsing file rhel6_top_16.12.19.1100.dat ... Parsing file rhel6_ps_16.12.19.1100.dat ... Dates accepted. Verifying valid begin/end data points... Validating times in the archive... Recalibrating data... Scanning file headers for version and platform info... Parsing file rhel6_iostat_16.12.19.1100.dat ... Parsing file rhel6_vmstat_16.12.19.1100.dat ... Parsing file rhel6_netstat_16.12.19.1100.dat ... Parsing file rhel6_top_16.12.19.1100.dat ... Parsing file rhel6_ps_16.12.19.1100.dat ... A new analysis file analysis/rhel6_1482117679897.txt has been created. #生成的分析报告在analysis目录中 [oracle@rhel6 oswbb]$ more analysis/rhel6_1482117679897.txt This report is best viewed in a fixed font editor like textpad... OSWatcher Analyzer Input Archive: archive Archive Source Dest: /home/oracle/oswatcher/oswbb/archive Archive Start Time: Dec 19 11:01:57 2016 Archive Stop Time: Dec 19 11:20:59 2016 Hostname: RHEL6 OS Version: Linux Snapshot Freq: 15 CPU COUNT: 2 ...... Subsystem Status ------------------------ CPU OK MEMORY OK I/O WARNING NET OK ......
MOS文档 ID 461053.1有详细介绍使用分析工具。