本文來自:http://sunligang-chenghaijie./2009/01/nmon.html
Nmon 工具是 IBM 提供的免費(fèi)的監(jiān)控 AIX 系統(tǒng)與 Linux 系統(tǒng)資源的工具。該工具可將服務(wù)器的系統(tǒng)資源耗用情況收集起來并輸出一個(gè)特定的文件,并可利用 excel 分析工具進(jìn)行數(shù)據(jù)的統(tǒng)計(jì)分析,非常利用 UNIX 或者 Linux 系統(tǒng)的性能數(shù)據(jù)分析。Nmon 工具使用起來非常簡(jiǎn)單,下面將分步驟介紹如何使用該工具。
一、安裝 nmon 首先我們?cè)?IBM 的官方網(wǎng)站上下載 nmon 工具,下載時(shí)需注意要下載對(duì)應(yīng)的系統(tǒng)版本。我們這里以 debian31 為例,下載的是 nmon_x86_11f.zip 版本,該版本支持 ubuntu。下載后解壓,改名為 nmon 并上傳到 Linux 中。在 Linux 的終端中輸入 ls 可以看到: slg@slg-desktop:~/桌面/GVS項(xiàng)目/nmon$ ls nmon_x86_debian31 nmon_x86_knoppix5 nmon_x86_rhel3 nmon_x86_sles10 nmon_x86_fedora5 nmon_x86_rhel2 nmon_x86_rhel4 nmon_x86_sles9
為了能夠正常的使用 nmon 工具,我們需要修改相關(guān)文件的權(quán)限。我們這里所使用的 Linux 系統(tǒng)是 ubuntu,所以,我們僅修改”nmon_x86_debian31”文件 的權(quán)限即可。為了方便,直接改為 777,命令如下:chmod 777 nmon_x86_debian31修改完成后,我們就完成了 nmon 工具的安裝,接下來介紹一下該工具的使用。
二、使用 nmon nmon 工具使用非常簡(jiǎn)單。首先我們啟動(dòng)該工具,在 nmon 目錄下,輸入 ./nmon_x86_debian31 打開界面,根據(jù)提示信息即可進(jìn)行操作, ┌nmon─11f─────────────────────Hostname=slg-desktop──Refresh= 2secs ───10:12.08──────────────────────────────────────────────┐ │ │ │ ------------------------------ For help type H or ... │ │ # # # # #### # # nmon -? - hint │ │ ## # ## ## # # ## # nmon -h - full │ │ # # # # ## # # # # # # │ │ # # # # # # # # # # To start the same way every time │ │ # ## # # # # # ## set the NMON ksh variable │ │ # # # # #### # # │ │ ------------------------------ │ │ │ │ Use these keys to toggle statistics on/off: │ │ 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 │ │───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ │ 如輸入c顯示cpu信息; CPU Utilisation ──────────────────────────────────────────────────────────────────────────────────────────────────────────│ │ +-------------------------------------------------+ │ │CPU User% Sys% Wait% Idle|0 |25 |50 |75 100| │ │ | Please wait gathering data │ │ +-------------------------------------------------+ │ │──────────────────────────────────────────────────────────────────────────────────────────
三、輸出文件
上面所講的只是在服務(wù)器監(jiān)控,我們真正需要的是如何收集這些數(shù)據(jù)并處理分析它們。nmon 提供了一個(gè) nmon_analyser 的分析工具,可利用 excel 進(jìn)行統(tǒng)計(jì)結(jié)果的分析。在測(cè)試的時(shí)候,我們可使用下列命令進(jìn)行數(shù)據(jù)的輸出: ./ nmon_x86_debian31 –fT –s 5 –c 5 上面命令的含義是,-f 輸出文件,-T 輸出最耗資源的進(jìn)程,-s 收集數(shù)據(jù)的時(shí)間間隔,-c 收集次數(shù)。比如,我們測(cè)試場(chǎng)景需要執(zhí)行 20 分鐘,那么我們需要每隔 10 秒監(jiān)控 Linux系統(tǒng)資源就可以寫成: ./ nmon_x86_debian31 –fT –s 10 –c 120 120 是次數(shù),也就是 20 分鐘/10 秒=120 次。完成后會(huì)在當(dāng)前目錄生成一個(gè).nmon 的文 件。如圖: slg@slg-desktop:~/桌面/GVS項(xiàng)目/nmon$ ls nmon_x86_debian31 nmon_x86_knoppix5 nmon_x86_rhel3 nmon_x86_sles10 slg-desktop_090113_1024.nmon nmon_x86_fedora5 nmon_x86_rhel2 nmon_x86_rhel4 nmon_x86_sles9 nmon 輸出文件的命名方式是服務(wù)器名_日期時(shí)間.nmon,我們?cè)跍y(cè)試結(jié)束后,可到相應(yīng)的目錄下提取這些文件。
四、分析數(shù)據(jù)
打開nmon analyser v334 設(shè)置宏的安全級(jí)別是低 ,之后點(diǎn)擊 Analyser NMON data 按鈕 輸入文件 保存成excel格式即可。 |