Linux下安装使用NMON监控、分析系统性能

Linux下安装使用NMON监控、分析系统性能

转载:http://www.cnblogs.com/yangxia-test/p/4836063.html

背景:今天在LoadRunner11.0中使用rstat监控linux过程中,始终提示如下错:

Linux下安装使用NMON监控、分析系统性能
Monitor name :UNIX Resources. Cannot initialize the monitoring on 10.201.76.152. Error while creating the RPC client. Ensure that the machine can be connected and that it runs the rstat daemon (use rpcinfo utility for this verification). Detailed error: RPC: Failed to create RPC client.
RPC-TCP: Failed to establish RPC server address.
RPC-TCP: Failed to communicate with the portmapper on host '10.201.76.152'.
RPC: RPC call failed.
RPC-TCP: recv()/recvfrom() failed.
RPC-TCP: Timeout reached. (entry point: CFactory::Initialize).    [MsgId: MMSG-47190]
Linux下安装使用NMON监控、分析系统性能

无奈,只好放弃这种方法。选择使用第三方工具nmon来监控linux.

简介:Nmon 是一个分析aix和linux性能的免费工具(其主要是ibm为自己的aix操作系统开发的,但是也可以应用在linux操作系统上),而nmon_analyser是nmon的一个工具可以把nmon生成的报告转化成excel报表的形式供我们查看。

环境:

[root@ip-172-199-0-33 nmon_result]# uname -m&&uname -r
x86_64
2.6.32-431.3.1.el6.x86_64
[root@ip-172-199-0-33 nmon_result]# cat /etc/redhat-release 
CentOS release 6.5 (Final)

一.下载nmon

根据CPU的类型选择下载相应的版本:
http://nmon.sourceforge.net/pmwiki.php?n=Site.Download

wget http://sourceforge.net/projects/nmon/files/download/nmon_x86_12a.zip/download

二.初始化nmon工具

unzip nmon_x86_12a.zip

Archive:  nmon_x86_12a.zip
  inflating: nmon_x86_rhel45
  inflating: nmon_x86_rhel52
  inflating: nmon_x86_sles9
  inflating: nmon_x86_sles10
  inflating: nmon_x86_ubuntu810
  inflating: nmon_x86_fedora10
  inflating: nmon_x86_opensuse10

根据不同的平台,初始化对应平台的nmon工具:

chmod u+x nmon_x86_rhel45
cp nmon_x86_rhel45 /usr/local/bin/nmon

三.运行nmon工具

当我们执行[root@localhost source]# nmon后出现一个帮助信息

注意:nmon是个交互式程序,当我们执行nmon的时候会出现一个交互窗口,我们执行相关的命令就会出现相关的信息。

nmon

Linux下安装使用NMON监控、分析系统性能

我们执行相关的命令,就会出现相关的信息了,比如这里我按c,就会显示cpu的相关信息,接下来我们紧接着按键盘m和n、d字母就会出现内存和网卡、磁盘的相关信息了。

Linux下安装使用NMON监控、分析系统性能

CPU、内存、磁盘和网络的消耗情况都被很直观的展现出来。

按q键,退出显示,其实就是这么简单。

四.生成nmon报告

1)采集数据

nmon -s10 -c60 -f -m /home/
ps -ef | grep nmon

参数解释:
-s10 每 10 秒采集一次数据。
-c60 采集 60 次,即为采集十分钟的数据。
-f 生成的数据文件名中包含文件创建的时间。
-m 生成的数据文件的存放目录。

当我们执行相关命令后,就在当前目录生成了一个以本主机名开头,以执行日期为规则,每十秒更新一次,nmon结尾的文件,并且我们通过ps命令会看到相关的nmon进程,这里我们当10分钟过去以后我们会发现相关nmon进程会消失的。

生成的文件名如: _150924_1306.nmon ,"" 是这台主机的主机名。

nmon -h查看更多帮助信息。

2)生成报表
下载 nmon analyser (生成性能报告的免费工具):
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Power%20Systems/page/nmon_analyser


   将之前生成的 nmon 数据文件传到 Windows 机器上,用 Excel 打开分析工具 nmon analyser v46C.xls 。点击 Excel 文件中的 "Analyze nmon data" 按钮,选择 nmon 数据文件,这样就会生成一个分析后的结果文件: hostname_150924_1306.nmon.xls ,用 Excel 打开生成的文件就可以看到结果了。

如果宏不能运行,需要做以下操作:
Linux下安装使用NMON监控、分析系统性能

下面是在测试环境中生成的NMON报告截图:

Linux下安装使用NMON监控、分析系统性能

红色区域为不同指标的分析报告。

3)自动按天采集数据
在 crontab 中增加一条记录:

0 0 * * * root nmon -s300 -c288 -f -m /home/ > /dev/null 2>&1

300*288=86400 秒,正好是一天的数据。

五.遇到的问题

1.在运行nmon时,提示:sh /usr/bin/lsb_release: No such directory

解决方法:yum install redhat-lsb -y

2.bash: /usr/local/bin/rar: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

是因为64位系统中安装了32位程序

解决方法:yum install glibc.i686

重新安装以后还有如下类系错误 再继续安装包

error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
解决方法:yum install libstdc++.so.6