OSWatcher使用簡介

   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

wKiom1hXUYPQTcv4AAEdRuiDQcA027.png

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有詳細介紹使用分析工具。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章