nmon的使用

Linux性能評測工具之一:nmon篇

分類: 敏捷實踐
 

目錄(?)[+]php

 

1. nmon概述

1.1. 概述

nmon是收集AIX或Linux主機的性能數據並分析的工具,使用簡單易用。主要有兩個,一個是nmon採集數據的工具,通常名稱爲nmon_**,例如nmon_aix5.3,另外一個是分析結果的工具,它是一個excel的文件,名稱爲:nmon analyser v33A.xls。html

nmon在一個屏幕上顯示全部重要的性能優化信息,並動態地對其進行更新。還能夠將相同的數據捕獲到一個文本文件,便於之後對報告進行分析和繪製圖形。linux

nmon_analyser 工具以 NMON 性能工具生成的文件做爲輸入,而後將它們轉換爲 Microsoft Excel 電子表格,並自動地生成相應的圖形。shell

nmon 工具能夠爲 AIX 和 Linux 性能專家提供監視和分析性能數據的功能,其中包括: 性能優化

l CPU 使用率 服務器

l 內存使用狀況 網絡

l 內核統計信息和運行隊列信息 app

l 磁盤 I/O 速度、傳輸和讀/寫比率 less

l 文件系統中的可用空間 async

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

相關文章
相關標籤/搜索