1. nmon概述
1.1. 概述
nmon是收集AIX或Linux主机的性能数据并分析的工具,使用简单易用。主要有两个,一个是nmon采集数据的工具,一般名称为nmon_**,例如nmon_aix5.3,另一个是分析结果的工具,它是一个excel的文件,名称为:nmon analyser v33A.xls。
nmon在一个屏幕上显示所有重要的性能优化信息,并动态地对其进行更新。还可以将相同的数据捕获到一个文本文件,便于以后对报告进行分析和绘制图形。
nmon_analyser 工具以 NMON 性能工具生成的文件作为输入,然后将它们转换为 Microsoft Excel 电子表格,并自动地生成相应的图形。
nmon 工具可以为 AIX 和 Linux 性能专家提供监视和分析性能数据的功能,其中包括:
l CPU 使用率
l 内存使用情况
l 内核统计信息和运行队列信息
l 磁盘 I/O 速度、传输和读/写比率
l 文件系统中的可用空间
l 磁盘适配器
l 网络 I/O 速度、传输和读/写比率
l 页面空间和页面速度
l 消耗资源最多的进程
l 计算机详细信息和资源
IBM 没有提供对该工具的正式支持,并且您在使用它的时候必须自己承担相应的风险,但是您可以从中获得大量有价值的性能统计信息。其中,nmon for linux版本已经在2009年7月27日开放源码。
1.2. 适用范围
本文档为使用nmon作为性能测试中监控linux服务器的应用,提供使用规范和帮助。
1.3. 词汇表
词汇 |
解释 |
Nmon |
性能数据收集分析工具 |
Nmon analyser |
性能数据分析工具,excel文件 |
nmon_x86_sles10 |
Nmon在x86_sles10下二进制执行文件 |
1.4. 参考资料
Nmon在IBM的官方网站
http://www.ibm.com/developerworks/wikis/display/WikiPtype/nmon
nmon for linux的官方网站
http://nmon.sourceforge.net/pmwiki.php
文章一:《nmon 性能:分析 AIX 和 Linux 性能的免费工具》
http://www.ibm.com/developerworks/cn/aix/library/analyze_aix/
文章二:《nmon analyser——生成 AIX 性能报告的免费工具》
http://www.ibm.com/developerworks/cn/aix/library/nmon_analyser/index.html:
1.5. 获取该工具
下载nmon工具的可执行文件nmon_x86_sles10。
http://nmon.sourceforge.net/pmwiki.php?n=Site.Download
也可以下载源码自己编译特定的版本。(推荐这个)
http://nmon.sourceforge.net/pmwiki.php?n=Site.CompilingNmon
下载nmon Analyser V3.3
http://www.ibm.com/developerworks/wikis/display/Wikiptype/nmonanalyser
下载nmon Consolidator
http://www.ibm.com/developerworks/wikis/display/WikiPtype/nmonconsolidator
ibm的其他性能测试工具
http://www.ibm.com/developerworks/wikis/display/WikiPtype/Performance+Other+Tools
2. nmon
2.1. 安装
该工具是一个独立的二进制文件(不同的 AIX 或 Linux 版本中该文件也有所不同)。安装过程非常简单:
1. 将 nmon_x86_sles10文件复制到计算机,rz—>在弹出框选择nmon_x86_sles10。
2. 修改nmon_x86_sles10的文件权限,chmod 777 ./nmon_x86_sles10
3. 要启动 nmon 工具,输入 ./ nmon_x86_sles10。
2.2. 运行
Nmon可以交互式运行
l 启动该工具 ./ nmon_x86_sles10
l 使用单键命令来查看您所需要的数据。例如,要获取 CPU、内存和磁盘统计信息,启动 nmon 并输入: c m d
l 获取相关的帮助信息,按 h 键。
使用下面这些键来切换显示状态:
c = CPU l = CPU Long-term - = Faster screen updates
m = Memory j = Filesystems + = Slower screen updates
d = Disks n = Network V = Virtual Memory
r = Resource N = NFS v = Verbose hints
k = kernel t = Top-processes . = only busy disks/procs
h = more options q = Quit
2.3. 捕获数据到文件
捕获数据到文件,只要运行带 -f 标志的 nmon 命令。执行nmon –f ***后,nmon 将转为后台运行。要查看该进程是否仍在运行,可以输入: ps -ef | grep nmon。
示例:
每1秒捕获数据快照,捕获20次
nmon –f -s 1 -c 20
每30秒捕获数据快照,捕获120次,包含进程信息
nmon –ft -s 30 -c 120
命令将在当前目录中创建输出文件,其名称为: <hostname>_date_time.nmon。该文件采用逗号分隔值 (CSV) 的格式,并且可以将其直接导入到电子表格中,可进行分析和绘制图形
2.4. Nmon界面
进入界面
监控界面一
监控界面二
3. nmon_analyser
nmon_analyser 工具以 NMON 性能工具生成的文件作为输入,然后将它们转换为 Microsoft Excel 电子表格,并自动地生成相应的图形。
使用wps未能正确执行脚本生成*.xls文件。建议Excel™ 2000 或更高版本,必须在打开nmon_analyser选择启用宏。
nmon_analyser 工具设计用于最新版本的 nmon,但出于向后兼容性的考虑,也使用旧版本对其进行了测试。每当在对 nmon 进行更新时,同时也将对该工具进行更新,
4. 附录
4.1. Nmon帮助信息
参阅 nmon –h
Hint: nmon_x86_sles10 [-h] [-s <seconds>] [-c <count>] [-f -d <disks> -t -r <name>] [-x]
-h FULL help information
Interactive-Mode:
read startup banner and type: "h" once it is running
For Data-Collect-Mode (-f)
-f spreadsheet output format [note: default -s300 -c288]
optional
-s <seconds> between refreshing the screen [default 2]
-c <number> of refreshes [default millions]
-d <disks> to increase the number of disks [default 256]
-t spreadsheet includes top processes
-x capacity planning (15 min for 1 day = -fdt -s 900 -c 96)
Version - nmon 12c
For Interactive-Mode
-s <seconds> between refreshing the screen [default 2]
-c <number> of refreshes [default millions]
-g <filename> User Defined Disk Groups [hit g to show them]
- file = on each line: group_name <disks list> sapce separated
- like: database sdb sdc sdd sde
- upto 32 disk groups, disks can appear more than once
-b black and white [default is colour]
example: nmon_x86_sles10 -s 1 -c 100
For Data-Collect-Mode = spreadsheet format (comma separated values)
Note: use only one of f,F,z,x or X and make it the first argument
-f spreadsheet output format [note: default -s300 -c288]
output file is <hostname>_YYYYMMDD_HHMM.nmon
-F <filename> same as -f but user supplied filename
-r <runname> goes into spreadsheet file [default hostname]
-t include top processes in the output
-T as -t plus saves command line arguments in UARG section
-s <seconds> between snap shots
-c <number> of refreshes
-d <disks> to increase the number of disks [default 256]
-l <dpl> disks/line default 150 to avoid spreadsheet issues. EMC=64.
-g <filename> User Defined Disk Groups (see above)
-N include NFS Network File System
-I <percent> Include precoess and disks busy threshold (default 0.1)
don't save or show proc/disk using less than this percent
-m <directory> nmon changes to this directory before saving to file
-D Skip disk configuration sections
example: collect for 1 hour at 30 second intervals with top procs
nmon_x86_sles10 -f -t -r Test1 -s30 -c120
To load into a spreadsheet like Lotus 1-2-3:
sort -A *nmon >stats.csv
transfer the stats.csv file to your PC
Start 1-2-3 and then Open <char-separated-value ASCII file>
Capacity planning mode - use cron to run each day
-x sensible spreadsheet output for CP = one day
every 15 mins for 1 day ( i.e. -ft -s 900 -c 96)
-X sensible spreadsheet output for CP = busy hour
every 30 secs for 1 hour ( i.e. -ft -s 30 -c 120)
Set-up and installation
- this adds the disk % busy numbers (otherwise they are zero)
If you have hundreds of disk this can take 1% to 2% CPU
Interactive Mode Commands
key --- Toggles to control what is displayed ---
h = Online help information
r = Machine type, machine name, cache details and OS version + LPAR
c = CPU by processor stats with bar graphs
l = long term CPU (over 75 snapshots) with bar graphs
m = Memory stats
V = Virtual Memory and Swap stats
k = Kernel Internal stats
n = Network stats and errors
N = NFS Network File System
d = Disk I/O Graphs
D = Disk I/O Stats
o = Disk I/O Map (one character per disk showing how busy it is)
b = black and white mode (or use -b option)
. = minimum mode i.e. only busy disks and processes
key --- Other Controls ---
+ = double the screen refresh time
- = halves the screen refresh time
q = quit (also x, e or control-C)
0 = reset peak counts to zero (peak = ">")
space = refresh screen now
Startup Control
If you find you always type the same toggles every time you start
then place them in the NMON shell variable. For example:
export NMON=cmdrvtan
Others:
a) To you want to stop nmon - kill -USR2 <nmon-pid>
b) Use -p and nmon outputs the background process pid
c) To limit the processes nmon lists (online and to a file)
Either set NMONCMD0 to NMONCMD63 to the program names
or use -C cmd:cmd:cmd etc. example: -C ksh:vi:syncd
d) If you want to pipe nmon output to other commands use a FIFO:
mkfifo /tmp/mypipe
nmon -F /tmp/mypipe &
grep /tmp/mypipe
e) If nmon fails please report it with:
1) nmon version like: 12c
2) the output of cat /proc/cpuinfo
3) some clue of what you were doing
4) I may ask you to run the debug version
Copyright 2009 Nigel Griffiths
GNU General Public License <http://www.gnu.org/licenses/>.
Feedback welcome - http:/nmon.sourceforge.net
No warranty given or implied.
附录二:nmon参数:
参考http://www.ibm.com/developerworks/wikis/display/Wikiptype/nmonanalyser
nmon:
-f spreadsheet output format [note: default -s300 -c288]
Output file is <hostname>_YYYYMMDD_HHMM.nmon
-F <filename> same as -f but user supplied filename
-c <number> number of snapshots
-d requests disk service and wait times (DISKSERV and DISKWAIT)
-i <percent> Ignore processes using less than this amount of CPU when generating TOP section – useful for reducing data volumes
-g <filename> file containing disk group definitions
-l <dpl> number of hdisks per sheet - defaults to 150, maximum 250. See notes
-m <dir> NMON changes to this directory before saving the file
-r <runname> goes into spreadsheet file [default hostname]
-s <seconds> interval between snap shots
-x capacity planning (15 mins for 1 day = -fdt -s900 -c96)
-t include top processes in the output
-T as –t plus saves command line arguments in UARG section
-A include data for async I/O (PROCAIO) sections
-D prevents DISK sections being produced (useful when Disk Groups are being used because there are too many hdisks to process)
-E stops ESS sections being produced (necessary when Disk Groups are being used because there are too many vpaths to process)
-J prevents JFS sections being produced (prevents Excel errors when you have more than 255 filesystems)
-L includes LARGEPAGE section
-N include NFS sections
-S include WLM sections with subclasses
-W include WLM sections without subclasses
-Y include SUMMARY section (very efficient alternative to –t if PID level data is not required)
example: nmon_aix51 -F asterix.nmon -r Test1 -s6 -c12