使用OS Watcher监控操作系统

系统性能是一个综合性结果的体现。对最终用户而言,使用系统的体验感可能就是系统是不是跑得快、在规定时间内完成作业、业务高峰期能否快速打开页面。但是,对系统设计、开发和运维人员来讲,系统性能是一个综合性的指标,涉及系统各个组成部分的软硬件配置和运行状态。

 

对于数据库端出现的问题,我们可以使用诸如AWR报告、ASH报告进行全方位的监控和诊断。但是对于操作系统,我们通常需要专门的监控工具,甚至专门的软件。实际上,各个操作系统(AIXLinux)都提供了一些基本的性能监控检查工具,如topasiostat等,我们需要做的就是周期性的进行工具调用和数据收集、分析。Oracle提供的免费工具OS Watcher就是这样的利器。

 

1、软件获取和安装

 

OS WatcherOracle提供给授权客户的一个免费使用小工具,我们可以通过官方支持网站MOS上下载,文章号Note: 301137.1

 

我们从网站下载的文档是一个压缩格式包文件。OS Watcher作为轻量型性能监控软件,自身运行的低消耗是非常重要的。OS Watcher本身不需要安装,软件就是一系列的shell脚本文件。

 

笔者下载的文件是最新的版本6.01,压缩格式文件为oswbb601.tar。顺便说一句,OS Watcher目前支持LinuxUnix系列的操作系统,Windows平台目前还不支持~

 

安装OS Watcher的过程及其简单,我们首先创建一个专门运行的目录,之后将文件传入到目录中。

 

 

[root@bspdev /]# mkdir osw

[root@bspdev /]# ls -l | grep osw

drwxr-xr-x  2 root   root      4096 Feb 22 14:45 osw

[root@bspdev /]#

 

[root@bspdev osw]# ls -l

total 1316

-rw-r--r-- 1 root root 1341440 Feb 22 14:57 oswbb601.tar

 

 

使用tar命令解压文件。

 

[root@bspdev osw]# tar xvf oswbb601.tar

oswbb/

oswbb/src/

oswbb/src/tombody.gif

(篇幅原因,有省略……)

oswbb/iosub.sh

oswbb/xtop.sh

[root@bspdev osw]#

 

[root@bspdev osw]# ls -l

total 1320

drwxr-xr-x 9 oracle oinstall    4096 Feb 21 05:09 oswbb

-rw-r--r-- 1 root   root     1341440 Feb 22 14:57 oswbb601.tar

 

 

oswbb目录中,我们可以看到执行目录和脚本。

 

 

[oracle@bspdev osw]$ cd oswbb

[oracle@bspdev oswbb]$ ls -l

total 344

drwxr-xr-x 2 oracle oinstall   4096 Feb 15 00:08 analysis

-rwxr-xr-x 1 oracle oinstall     67 Feb 19 01:37 call_du.sh

-rwxr-xr-x 1 oracle oinstall     68 Nov 13 01:31 call_sar.sh

(篇幅原因,有省略……)

-rwxr-xr-x 1 oracle oinstall    544 Nov  8 00:55 vmsub.sh

-rwxr-xr-x 1 oracle oinstall   1404 Oct 11 01:53 xtop.sh

[oracle@bspdev oswbb]$

 

 

我们就完成了所有安装步骤,下面开始运行程序。

 

2、程序运行和性能数据收集

 

OS Watcher的本质就是借助操作系统自身的性能数据收集接口,定期以作业的方式调用程序,并且收集数据。OS Watcher基于的几个常用性能监控程序,如topasvmstatiostat。我们调用OS Watcher的时候,一定要注意调用用户的权限情况,要有权限执行这几个程序。

 

开启监控过程,我们需要调用startOSWbb.sh脚本,输入监控时间参数信息之后,监控过程就自动开始了。

 

startOSWbb.sh参数有四个,头两个是我们最常使用的,监控收集间隔和运行时间。OS Watcher会在后台运行,在特定间隔启动收集,并且将数据收集在OS Watcher的归档archive信息库中。间隔时间的参数单位是秒。运行时间设置程序运行的时间,单位是小时,经过了这个时间,OS Watcher自动终止。

 

 

第三个参数是存储数据格式,如果收集时间很长,收集数据可能需要压缩。第三个参数就是设置压缩格式的。最后一个不经常需要设置,就是数据收集的目录。如果我们不设置,会选择在oswbb下创建一个archive目录进行保存。

 

下面我们尝试启动程序。

 

 

--30s收集一次,运行1小时

[oracle@bspdev oswbb]$ ./startOSWbb.sh 30 1 gzip

[oracle@bspdev oswbb]$ Info...Zip option IS specified.

Info...OSW will use gzip to compress files.

Setting the archive log directory to/osw/oswbb/archive

 

--工具确认

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.

 

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 = 1

 

Discovery completed.

 

 

Starting OSWatcher Black Box v6.0.1  on Fri Feb 22 15:04:30 CST 2013

With SnapshotInterval = 30

With ArchiveInterval = 1

 

OSWatcher Black Box - Written by Carl Davis, Center of Expertise,

Oracle Corporation

For questions on install/usage please go to MOS (Note:301137.1)

If you need further assistance or have comments or enhancement

requests you can email me Carl.Davis@Oracle.com

 

Data is stored in directory: /osw/oswbb/archive

 

Starting Data Collection...

 

--开始收集

oswbb heartbeat:Fri Feb 22 15:04:35 CST 2013

 

 

从工具检测上,OS Watcher涉及到CPUIO Disk、内存和网络多个方面。一般OS层面的性能测试基本已经涵盖。

 

每隔一个时间间隔,OS Watcher就会在后台启动收集信息。

 

 

 

oswbb heartbeat:Fri Feb 22 15:04:35 CST 2013

oswbb heartbeat:Fri Feb 22 15:05:10 CST 2013

oswbb heartbeat:Fri Feb 22 15:05:44 CST 2013

oswbb heartbeat:Fri Feb 22 15:06:19 CST 2013

 

(后台运行)

 

[oracle@bspdev oswbb]$ ps -ef | grep OSW

oracle    2573     1  0 15:04 pts/0    00:00:01 /bin/sh ./OSWatcher.sh 30 1 gzip

oracle    2726  2573  0 15:04 pts/0    00:00:00 /bin/sh ./OSWatcherFM.sh 1 /osw/oswbb/archive

oracle    5266  2525  0 15:07 pts/0    00:00:00 grep OSW

[oracle@bspdev oswbb]$

 

 

除了经过设置时间终止监控外,OS Watcher还可以通过stopOSWbb.sh脚本来终止执行。

 

 

[oracle@bspdev oswbb]$ ./stopOSWbb.sh

[oracle@bspdev oswbb]$ ps -ef | grep OSW

oracle    3042  2435  0 15:47 pts/2    00:00:00 grep OSW

 

 

统计收集的数据,都在archive目录下分类保存。

 

 

[oracle@bspdev osw]$ du

4       ./oswbb/gif

228     ./oswbb/docs/OSWatcher_Black_Box

776     ./oswbb/docs/The_Analyzer

1008    ./oswbb/docs

4       ./oswbb/tmp

4       ./oswbb/locks

20      ./oswbb/archive/oswmpstat

276     ./oswbb/archive/oswslabinfo

4       ./oswbb/archive/oswprvtnet

20      ./oswbb/archive/oswmeminfo

20      ./oswbb/archive/oswiostat

152     ./oswbb/archive/oswps

12      ./oswbb/archive/oswvmstat

32      ./oswbb/archive/oswnetstat

76      ./oswbb/archive/oswtop

616     ./oswbb/archive

76      ./oswbb/src

4       ./oswbb/profile

4       ./oswbb/analysis

2040    ./oswbb

3360    .

 

 

在目录下的确有数据收集到。下面我们一起来看看如何进行数据的分析处理。

 

3OS Watcher收集结果处理

 

OS Watcher的全名为Operation System Watcher Black Box(简称oswbb)。oswbb只负责收集数据,并不能够直接分析结果。Oracleoswbb 4.0之后,提供了专门的分析图形化工具,oswbbaOperation System Watcher Black Box Analyzer)被加入到oswbb工具包中,对数据可以进行完全的分析和处理。

 

oswbba是一个基于java的软件,要求运行系统中必须安装单独的java程序,并且配置适当的处理空间。由于oswbb是一个纯绿色软件,我们甚至可以把数据拷贝到windows环境上进行处理。

 

 

--运行命令,oswbba.jaroswbb目录下

C:\Users\Tomas\Desktop\OSWatch\oswbb>java -jar oswbba.jar -i C:\Users\Tomas\Desktop\OSWatch\oswbb\archive

 

Starting OSW Black Box Analyzer V6.0.1

OSWatcher Black Box Analyzer Written by Oracle Center of Expertise

Copyright (c)  2012 by Oracle Corporation

 

Parsing Data. Please Wait...

 

Scanning file headers for version and platform. info...

 

 

Parsing file bspdev.localdomain_iostat_13.02.22.1500.dat ...

Timestamp Error. Expected format: May 3 16:11:12 2006.

Timestamp Error. Found format: Feb 22 15:04:35 2013

Timestamp Error. Expected format: May 3 16:11:12 2006.

Timestamp Error. Found format: Feb 22 15:05:10 2013

Timestamp Error. Expected format: May 3 16:11:12 2006.

 

 

An exception occured in insertVmstatLists on line 0

An exception occured in insertVmstatLists on line 0

 

Parsing file bspdev.localdomain_netstat_13.02.22.1500.dat ...

Parsing file bspdev.localdomain_top_13.02.22.1500.dat ...

 

No data found in input archive directory C:\Users\Tomas\Desktop\OSWatch\oswbb\archive

Please rerun oswbba with proper input directory containing OSW archive data.

Program aborting...

 

 

oswbba的处理包oswbba.jar就保存在oswbb目录中。参数-i表示处理的数据目录。此外,我们还有-START-STOP参数用于执行处理的时间范围。

 

但是,在上面的调用中,我们失败了,主要原因是时间格式的差异让oswbba无法找到对应的处理文件。我们在linux环境上收集数据使用英文格式,所以,在Windows处理平台上,也需要进行转换。

 

我们只需要在控制面板的语言时间格式中,选择英文格式就可以了。

 

 

C:\Users\Tomas\Desktop\OSWatch\oswbb>java -jar oswbba.jar -i C:\Users\Tomas\Des

top\OSWatch\oswbb\archive

 

Starting OSW Black Box Analyzer V6.0.1

OSWatcher Black Box Analyzer Written by Oracle Center of Expertise

Copyright (c)  2012 by Oracle Corporation

 

Parsing Data. Please Wait...

 

Scanning file headers for version and platform. info...

Parsing file bspdev.localdomain_iostat_13.02.22.1500.dat ...

Parsing file bspdev.localdomain_vmstat_13.02.22.1500.dat ...

Parsing file bspdev.localdomain_netstat_13.02.22.1500.dat ...

Parsing file bspdev.localdomain_top_13.02.22.1500.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 P to Generate A Profile

Enter A to Analyze Data

Enter Q to Quit Program

 

Please Select an Option:

 

 

oswbb是命令行式的结构,通过输入数字或者字母来进行控制。从上面提示中,我们输入1-5数字,就可以显示出对应参数的趋势变化曲线图。而6-8选项索性会直接将图像生成.gif格式文件保存下来,方便后续处理。L-Q主要是控制参数,用来修改处理位置和范围。

 

下图是一张处理过的结果图。

 

 

 

格式非常适合数据分析和报告书写。

 

4、结论

 

OS Watcher及其分析工具,是非常方便的性能监控程序。在很多场合下,结合数据库原有的AWR报告,可以让我们更加全面的了解系统瓶颈,优化系统。

fj.pngOSWg_OS_Block_Queue.gif

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17203031/viewspace-754646/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/17203031/viewspace-754646/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
osquery 是 SQL 驱动的分析和监控操作系统的工具,是操作系统分析框架,支持 OS X 和 Linux 系统。osquery 能帮助监控和分析低水平的操作系统,提供更直观的性能监控osquery 在操作系统中就像是一个高性能的关系数据库,允许你编写基于 SQL 的查询语句来洞察操作系统的数据。使用 osquery,SQL 表代表如下抽象概念:运行时的进程 加载内核模块开放网络连接 SQL 表通过一个简单的可扩展 API 实现,各种表已经存在并且还在不断增加。为了更好的理解 osquery,看看下面的 SQL 查询:-------------------------------------------------------- -- get the name, pid and attached port of all processes  -- which are listening on all interfaces -------------------------------------------------------- SELECT DISTINCT    process.name,    listening.port,    process.pid FROM processes AS process JOIN listening_ports AS listening ON process.pid = listening.pid WHERE listening.address = '0.0.0.0';-------------------------------------------------------- -- find every launchdaemon on an OS X host which  --   * launches an executable when the operating  --     system starts --   * keeps the executable running  -- return the name of the launchdaemon and the full  -- path (with arguments) of the executable to be ran. -------------------------------------------------------- SELECT    name,    program || program_arguments AS executable  FROM launchd  WHERE    (run_at_load = 'true' AND keep_alive = 'true')  AND    (program != '' OR program_arguments != '');这些查询可以:在特定条件下探索操作系统状态通过执行调度程序来监控操作系统的主机状态启动使用osquery api的自定义应用程序

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值