https://www.anbob.com/archives/1143.html
OS Watcher简称OSW(oswbb),用于收集并归档操作系统cpu,memery,disk io,network等相关信息的工具,是oracle提供的脚本工具集,全是shell编写,OSW内部是使用操作系统提供的基本命令来收集数据,给系统带来的额外负载可以安全忽略,收集策略是放在后台定期间隔一段时间自动收集,并可以设定数据保留时间,定期清理。
这个工具包可以从Metalink下载。Metalink Note:301137.1, 当前最新为oswbb840版本, 在当前较新的ORACLE 19C RAC安装时,如果选择安装了 TFA 工具集,osw目前已是属于TFA一部分也可以独立安装, 查看当前系统是否启用OSW, 使用 ps -ef|grep osw 查看 oswbb进程是否存在就可以。
提供一个百度云盘地址
链接:https://pan.baidu.com/s/1nxHV07WQLTw7Y2Kl5FgxUg?pwd=ridc
提取码:ridc
OSW is certified to run on the following platforms:
1.AIX
2.Tru64
3.Solaris
4.HP-UX
5.Linux
安装很方便,下载后就是一个压缩包,前期版就不到300K,当前也就5M左右,解压就可以使用
[root@oel7db1 ~]# md5sum oswbb840.tar ccfe01232d1e28e28e5d3999ade773c2 oswbb840.tar [root@oel7db1 ~]# ls -l oswbb840.tar -rw-r--r-- 1 root root 5253120 Oct 1 18:21 oswbb840.tar
下面我开始在rhel linux上试验
[root@oel7db1 ~]# tar -xvf oswbb840.tar oswbb/ oswbb/uncpr.bat oswbb/sarsub.sh oswbb/psmemsub.sh oswbb/stopOSWbb.sh oswbb/analysis/ oswbb/piddsub.sh oswbb/arpsub.sh oswbb/docs/ oswbb/docs/OSWatcher/ oswbb/docs/OSWatcher/oswbb_README.txt ... [root@oel7db1 oswbb]# ll total 476 drwxr-xr-x 2 oracle dba 6 Nov 20 2019 analysis drwxr-xr-x 2 oracle dba 6 Nov 20 2019 archive -rwxrwxrwx 1 oracle dba 546 Jul 15 2019 arpsub.sh -rwxrwxrwx 1 oracle dba 67 Jul 15 2019 call_du.sh -rwxrwxrwx 1 oracle dba 68 Jul 15 2019 call_sar.sh -rwxrwxrwx 1 oracle dba 71 Jul 15 2019 call_uptime.sh drwxrwxrwx 2 oracle dba 6 Nov 20 2019 data drwxrwxrwx 4 oracle dba 76 Nov 20 2019 docs -rwxrwxrwx 1 oracle dba 665 Jul 15 2019 Example_extras.txt -rwxrwxrwx 1 oracle dba 1864 Jul 15 2019 Exampleprivate.net -rwxrwxrwx 1 oracle dba 3990 Jul 15 2019 genprvnet.sh drwxrwxrwx 2 oracle dba 6 Nov 20 2019 gif -rwxrwxrwx 1 oracle dba 795 Jul 15 2019 ifconfigsub.sh -rwxrwxrwx 1 oracle dba 743 Jul 15 2019 iosub.sh drwxrwxrwx 2 oracle dba 6 Nov 20 2019 locks -rwxrwxrwx 1 oracle dba 1507 Jul 15 2019 ltop.sh -rwxrwxrwx 1 oracle dba 542 Jul 15 2019 mpsub.sh -rwxrwxrwx 1 oracle dba 745 Jul 15 2019 nfssub.sh -rwxrwxrwx 1 oracle dba 8035 Jul 15 2019 OSWatcherFM.sh -rwxrwxrwx 1 oracle dba 55817 Nov 20 2019 OSWatcher.sh -rw-r--r-- 1 oracle dba 289876 Nov 20 2019 oswbba.jar -rwxrwxrwx 1 oracle dba 414 Jul 15 2019 oswib.sh -rwxrwxrwx 1 oracle dba 579 Jul 15 2019 oswnet.sh -rwxrwxrwx 1 oracle dba 825 Jul 15 2019 oswrds.sh -rwxrwxrwx 1 oracle dba 524 Jul 15 2019 oswsub.sh -rwxrwxrwx 1 oracle dba 561 Jul 15 2019 piddsub.sh -rwxrwxrwx 1 oracle dba 565 Jul 15 2019 pidsub.sh -rwxr-xr-x 1 root root 40 Oct 1 18:24 private.net -rwxrwxrwx 1 oracle dba 1481 Jul 15 2019 psmemsub.sh -rwxrwxrwx 1 oracle dba 557 Jul 15 2019 sarsub.sh drwxrwxrwx 7 oracle dba 126 Nov 20 2019 src -rwxrwxrwx 1 oracle dba 2574 Jul 15 2019 startOSWbb.sh -rwxrwxrwx 1 oracle dba 752 Jul 15 2019 stopOSWbb.sh -rwxrwxrwx 1 oracle dba 819 Jul 15 2019 tar_up_full_archive.sh -rwxrwxrwx 1 oracle dba 8234 Jul 15 2019 tar_up_partial_archive.sh drwxr-xr-x 2 oracle dba 6 Nov 20 2019 tmp -rwxrwxrwx 1 oracle dba 527 Jul 15 2019 topaix.sh -rwxrwxrwx 1 oracle dba 414 Nov 14 2019 uncpr.bat -rwxrwxrwx 1 oracle dba 545 Jul 15 2019 vmsub.sh -rwxrwxrwx 1 oracle dba 571 Jul 15 2019 xensub.sh -rwxrwxrwx 1 oracle dba 1486 Jul 15 2019 xtop.sh
— 确认所有.sh文件有x执行权限,如果没有 需要授权
[oracle@orazhang osw]$ chmod +x *.sh
对于RAC环境需要配置一下对interconnect使用的private的监控private.net文件, 确认操作系统有traceroute和ifconfig命令, 如果是19c自带TFA方式安装启用的osw不需要配置private.net ,已自动配置完,利用的是osw自带目录中的genprvnet.sh可以生成private.net,当然也可以自己vi 创建这个文件, 如果是RAC 环境,需要上传oswbb 到每个节点,手动执行
[oracle@orazhang osw]$sh genprvnet.sh
生成当前目录上private.net文件,注意要用x执行权限,如果是vi 手动创建,记的
[oracle@orazhang osw]$ chmod +x private.net
vi 创建private.net的方式是从自带的Exampleprivate.net文件内容中,复制一段适合自己的操作系统平台的内容。如LINUX平台private.net最终内容如下
[oracle@orazhang osw]$ cat private.net ###################################################################### #Linux Example ###################################################################### echo "zzz ***"`date` traceroute -r -F 192.68.1.xxx traceroute -r -F 192.68.1.xxx ###################################################################### # DO NOT DELETE THE FOLLOWING LINE!!!!!!!!!!!!!!!!!!!!! ###################################################################### rm locks/lock.file
注意: 上面的traceroute 部分换成自己RAC 环境的实际的private 网络IP, 如可以从cat /etc/hosts中查找private的IP地址。每个实例1条,如4个实例为4条,所有实例的private.net内容一样,可以复制,也可以增加自己指定的探测ip, 如Dataguard。
启动运行./startOSW.sh,后可选3个参数
./startOSW.sh <ARG1> <ARG2> <ARG3>
ARG1:表示收集间隔时间,默认为30秒
ARG1:表示数据保留时间,默认为48小时
ARG3:gzip或不跟,加gzip表示用gzip去压缩收集到的数据
注意:首次运行时会在osw目录下自动 创建archive子目录,用于存放收集到的数据,都是以文件格式存放,间隔30秒采集一次并保留10小时,一般需要120M左右的空间。
调用前先要先确保安装sysstat
[oracle@orazhang osw]$ rpm -qa sysstat sysstat-7.0.4-2.fc7
建议启动方式
[oracle@orazhang osw]$ sh startOSWbb.sh 3 72 gzip &
以3秒为间隔,保留最后72小时的数据,对于超过保留期限的数据,File Manager 会自动清理(File Manager 每隔一个小时调度一次),如果进程数较多如,如超过1万里 ps内容可能占空间较大,注意磁盘使用率,可以缩短保留时间如把72改为24.
[oracle@orazhang osw]$ Testing for discovery of OS Utilities... VMSTAT found on your system. IOSTAT found on your system. MPSTAT found on your system. NETSTAT found on your system. TOP found on your system. Discovery completed. Starting OSWatcher V2.0.2 on Wed Sep 28 16:14:43 CST 2011 With SnapshotInterval = 3 With ArchiveInterval = 4 OSWatcher - Written by Carl Davis, Center of Expertise, Oracle Corporation Starting Data Collection... osw heartbeat:Wed Sep 28 16:14:43 CST 2011 osw heartbeat:Wed Sep 28 16:14:46 CST 2011 osw heartbeat:Wed Sep 28 16:14:49 CST 2011 ...
启动后会一直监听,后台一直运行,关闭ssh窗口就可以。
停止OSW
[oracle@orazhang osw]$sh stopOSWbb.sh
分析工具
调用OSWg.jar,调用图形界面查看曲线图
[oracle@orazhang ~]$ export DISPLAY=192.168.3.140:0.0
[oracle@orazhang ~]$ ls
delete.sql Desktop firefox login.sql oraInventory osw rda rdesktop-1.7.0 record rmanfullbak.sh sql wxWidgets-2.9.1
[oracle@orazhang ~]$ cd osw
[oracle@orazhang osw]$ java -version
java version “1.4.2”
gij (GNU libgcj) version 4.1.2 20070626 (Red Hat 4.1.2-14)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[oracle@orazhang osw]$ java -jar OSWg.jar -i /home/oracle/osw/archive
Starting OSWg V2.0.4
OSWatcher Graph Written by Oracle Center of Expertise
Copyright (c) 2007 by Oracle Corporation
Parsing Data. Please Wait…
Parsing file orazhang_iostat_09.28.11.1600.dat …
Parsing file orazhang_vmstat_09.28.11.1600.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 Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program
Please Select an Option:1
>>> Input Error: null
[oracle@orazhang osw]$ which java
/usr/bin/java
[oracle@orazhang osw]$ export PATH=/u01/app/oracle/product/10.2.0/db_1/jre/1.4.2/bin:$PATH
[oracle@orazhang osw]$ java -version
java version “1.4.2_08”
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
[oracle@orazhang osw]$ which java
/u01/app/oracle/product/10.2.0/db_1/jre/1.4.2/bin/java
[oracle@orazhang osw]$ java -jar OSWg.jar -i /home/oracle/osw/archive
Starting OSWg V2.0.4
OSWatcher Graph Written by Oracle Center of Expertise
Copyright (c) 2007 by Oracle Corporation
Parsing Data. Please Wait…
Parsing file orazhang_iostat_09.28.11.1600.dat …
Parsing file orazhang_vmstat_09.28.11.1600.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 Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program
Please Select an Option:1
可以看到图形了
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 Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program
Please Select an Option:2
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 Specify Different Time Scale
Enter D to Return to Default Time Scale
Enter R to Remove Currently Displayed Graphs
Enter Q to Quit Program
Please Select an Option:q
note:
生成后在调用图形是一定要注意java的版本信息,GNU libgcj是有问题,用oracle自带的就可以10g自带1.4,11G j是java 5