linux性能監控分析及通過nmon_analyse生成分析報表


nmon是一款分析 AIX 和 Linux 性能的免費工具

nmon 工具還可以將相同的數據捕獲到一個文本文件,便於以后對報告進行分析和繪制圖形。輸出文件采用電子表格的格式 (.csv)。


 


性能介紹


nmon 工具可以為 AIX 和 Linux 性能專家提供監視和分析性能數據的功能,其中包括:

  • CPU 使用率
  • 內存使用情況
  • 內核統計信息和運行隊列信息
  • 磁盤 I/O 速度、傳輸和讀/寫比率
  • 文件系統中的可用空間
  • 磁盤適配器
  • 網絡 I/O 速度、傳輸和讀/寫比率
  • 頁面空間和頁面速度
  • CPU 和 AIX 規范
  • 消耗資源最多的進程
  • IBM HTTP Web 緩存
  • 用戶自定義的磁盤組
  • 計算機詳細信息和資源
  • 異步 I/O,僅適用於 AIX
  • 工作負載管理器 (WLM),僅適用於 AIX
  • IBM TotalStorage® Enterprise Storage Server® (ESS) 磁盤,僅適用於 AIX
  • 網絡文件系統 (NFS)
  • 動態 LPAR (DLPAR) 更改,僅適用於面向 AIX 或 Linux 的 pSeries p5 和 OpenPower

還包括一個用來從 nmon 的輸出生成圖形並創建可以在 Web 站點顯示的 .gif文件的新工具。


 

工具運行

* AIX® 4.1.5、4.2.0、4.3.2 和 4.3.3(nmon Version 9a:該版本的功能已經確定,並且不會對其進行進一步的開發。)
* AIX 5.1、5.2 和 5.3(nmon Version 10:該版本現在支持 AIX 5.3 和基於 POWER5™ 處理器的計算機,並且提供了 SMT 和共享 CPU 微分區的支持。)
* pSeries® p5 和 OpenPower™ 上的 Linux™ SUSE SLES 9、Red Hat EL 3 和 4、Debian
* Linux SUSE、Red Hat 和許多最新的 x86(32 位模式的 Intel 和 AMD)上的發布版
* zSeries® 或 mainframe 上的 Linux SUSE 和 Red Hat
 

安裝
 
該工具是一個獨立的二進制文件(不同的 AIX 或 Linux 版本中該文件也有所不同),您可以在五秒鍾內完成該工具的安裝,如果您的輸入速度更快的話,也許時間更短。安裝過程非常簡單:
  •  將 nmonXXX.tar.Z 文件復制到計算機。如果使用 FTP,請記住使用二進制模式。注意:示例中的 XXX 由實際的版本代替。
  • 要解壓該文件,可以運行 uncompress nmonXX.tar.Z。
  •  要提取該文件,可以運行 tar xvf nmonXX.tar。
  •  閱讀自述文件。
  • 啟動 nmon 工具,輸入 nmon。
  •  如果您是 root 用戶,可能需要輸入 ./nmon。

下面介紹下安裝工具步驟,其實安裝還是挺方便挺簡單的

 

打開這個網站下載符合自己操作系統的硬件的相關nmon版本的軟件到linux本地。
小七這邊用的是CentOS6  64位 下載的是  nmon16d_x86.tar.gz 9MB  (也可以直接點擊名字下載)
[root@lamw /home/lam7/nmon]# ls
nmon16d_x86.tar.gz nmon_analyser_v51_2.zip

將下載的 nmon16d_x86.tar.gz 解壓

 

[root@lamw /home/lam7/nmon]# tar -xzvf nmon16d_x86.tar.gz

 

然后會到解壓出來好多類型不同平台的二進制nmon,筆者這里的系統是nmon_x86_64_centos6,所以給nmon_x86_64_centos6文件執行權限

找到對應的linux版本

 不知道版本的可以輸入

[root@lamw /root]# lsb_release -a 查看版本

 

 

[root@lamw /home/lam7/nmon]# chmod u+x nmon_x86_64_centos6

 筆者這邊把  nmon_x86_64_centos6 文件名稱改成“nmon”了方便后續執行  (PS:如果不改文件名稱可以直接  ./nmon_x86_64_centos6去執行)

然后就可以用 ./nmon去執行了

 

[root@lamw /home/lam7/nmon]# ./nmon

nmon是個交互式程序,當我們執行nmon的時候會出現一個交互窗口,我們執行相關的命令就會出現相關的信息。

比如這里我按c,就會顯示cpu的相關信息

 

 根據自己需要監控的數據直接輸入相關信息即可,按H 可以查看對應的命令幫助解釋

 

 按q鍵,退出顯示,其實就是這么簡單。


 

下面通過nmon_analyse生成分析報表

nmon -h 可以查看幫助信息

Hint for nmon version 16d
    Full Help Info : nmon -h

    On-screen Stats: nmon
    Data Collection: nmon -f [-s <seconds>] [-c <count>] [-t|-T]
    Capacity Plan  : nmon -x
Interactive-Mode:
    Read the Welcome screen & at any time type: "h" for more help
    Type "q" to exit nmon

For Data-Collect-Mode
    -f            Must be the first option on the line (switches off interactive mode)
                  Saves data to a CSV Spreadsheet format .nmon file in then local directory
                  Note: -f sets a defaults -s300 -c288    which you can then modify
    Further Data Collection Options:
    -s <seconds>  time between data snapshots
    -c <count>    of snapshots before exiting
    -t            Includes Top Processes stats (-T also collects command arguments)
    -x            Capacity Planning=15 min snapshots for 1 day. (nmon -ft -s 900 -c 96)
---- End of Hints
---- Full Help Information for nmon 16d

For Interactive and Data Collection Mode:
    User Defined Disk Groups (DG) - This works in both modes
    It is a work around Linux issues, where disks & partitions are mixed up in /proc files
    & drive driver developers use bizarre device names, making it trick to separate them.
    -g <filename> Use this file to define the groups
                  - On each line: group-name <disks-list>   (space separated list)
                  - Example line: database sdb sdc sdd sde
                  - Up to 64 disk groups, 512 disks per line
                  - Disks names can appear more than one group
    -g auto       - Will generate a file called "auto" with just disks from "lsblk|grep disk" output
     For Interactive use define the groups then type: g or G
     For Data Capture defining the groups switches on data collection

Data-Collect-Mode = spreadsheet format (i.e. comma separated values)
    Note: Use only one of f, F, R, x, X or z to switch on Data Collection mode
    Note: Make it the first argument then use other options to modify the defaults
    Note: Don't collect data that you don't want - it just makes the files too large
    Note: Too many snapshots = too much data and crashes Analyser and other tools
    Note: 500 to 800 snapshots make a good graph on a normal size screen
    Recommended normal minimal options: snapshots every 2 minutes all day: 
        Simple capture:      nmon -f  -s 120 -c 720
        With Top Procs:      nmon -fT -s 120 -c 720
        Set the directory:   nmon -fT -s 120 -c 720 -m /home/nag/nmon
        Capture a busy hour: nmon -fT -s   5 -c 720 -m /home/nag/nmon

For Data-Collect-Mode Options
    -f            spreadsheet output format [note: default -s300 -c288]
             output file is <hostname>_YYYYMMDD_HHMM.nmon
    -F <filename> same as -f but user supplied filename
             Not recommended as the default file name is perfect
    The other options in alphabetical order:
    -a            Include Accelerator GPU stats
    -b            Online only: for black and white mode (switch off colour)
    -c <number>   The number of snapshots before nmon stops
    -d <disks>    To set the maximum number of disks [default 256]
                  Ignores disks if the systems has 100's of disk or the config is odd!
    -D            Use with -g to add the Disk Wait/Service Time & in-flight stats
    -f and -F     See above
    -g <filename> User Defined Disk Groups (see above) - Data Capture: Generates  BBBG & DG lines
    -g auto       See above but makes the file "auto" for you of just the disks like sda etc.
    -h            This help output
    -I <percent>  Set the ignore process & disks busy threshold (default 0.1%)
                  Don't save or show proc/disk using less than this percent
    -l <dpl>      Disks per line in data capture to avoid spreadsheet width issues. Default 150. EMC=64.
    -m <directory> nmon changes to this directory before saving to file
                  Useful when starting nmon via cron
    -M         Adds MHz stats for each CPU thread. Some POWER8 model CPU cores can be different frequencies
    -N            Include NFS Network File System for V2, V3 and V4
    -p            nmon outputs the PID when it starts. Useful in scripts to capture the PID for a later safe stop.
    -r <runname>  Use in a benchmark to record the run details for later analysis [default hostname]
    -R          Old rrdtool format used by some - may be removed in the future. If you use this email Nigel
    -s <seconds>  Time between snap shots - with "-c count" decides duration of the data capture
    -t            Include Top Processes in the output
    -T            As -t plus it saves command line arguments in UARG section
    -U            Include the Linux 10 CPU utilisation stats (CPUUTIL lines in the file)
    -V            Print nmon version & exit immediately

    To manually load nmon files into a spreadsheet:
        sort -A *nmon >stats.csv
        Transfer the stats.csv file to your PC
        Start spreadsheet & then Open with type=comma-separated-value ASCII file
        This puts every datum in a different cell
        Now select the data of one type (same 1st column) and graph it
        The nmon Analyser & other tools do not need the file sorted.

Capacity Planning mode - use cron to run each day
    -x            Sensible spreadsheet output for one day
                  Every 15 mins for 1 day ( i.e. -ft -s 900 -c 96)
    -X            Sensible spreadsheet output for busy hour
                  Every 30 secs for 1 hour ( i.e. -ft -s 30 -c 120)
    -z            Like -x but the output saved in /var/perf/tmp assuming root user

Interactive Mode Keys in Alphabetical Order
    Start nmon then type the letters below to switch on & off particular stats
    The stats are always in the same order on-screen
    To see more stats: make the font smaller or use two windows

    Key --- Toggles on off to control what is displayed ---
    b   = Black and white mode (or use -b command line option)
    c   = CPU Utilisation stats with bar graphs (CPU core threads)
    C   = CPU Utilisation as above but concise wide view (up to 192 CPUs)
    d   = Disk I/O Busy% & Graphs of Read and Write KB/s
    D   = Disk I/O Numbers including Transfers, Average Block Size & Peaks (type: 0 to reset)
    g   = User Defined Disk Groups            (assumes -g <file> when starting nmon)
    G   = Change Disk stats (d) to just disks (assumes -g auto   when starting nmon)
    h   = This help information
    j   = File Systems including Journal File Systems
    k   = Kernel stats Run Queue, context-switch, fork, Load Average & Uptime
    l   = Long term Total CPU (over 75 snapshots) via bar graphs
    L   = Large and =Huge memory page stats
    m   = Memory & Swap stats
    M   = MHz for machines with variable frequency 1st=Threads 2nd=Cores 3=Graphs
    n   = Network stats & errors (if no errors it disappears)
    N   = NFS - Network File System
          1st NFS V2 & V3, 2nd=NFS4-Client & 3rd=NFS4-Server
    o   = Disk I/O Map (one character per disk pixels showing how busy it is)
          Particularly good if you have 100's of disks 
    q   = Quit
    r   = Resources: Machine type, name, cache details & OS version & Distro + LPAR
    t   = Top Processes: select the data & order 1=Basic, 3=Perf 4=Size 5=I/O=root only
    u   = Top Process with command line details
    U   = CPU utilisation stats - all 10 Linux stats:
          user, user_nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
    v   = Experimental Verbose mode - tries to make recommendations
    V   = Virtual Memory stats

    Key --- Other Interactive Controls ---
    +   = Double the screen refresh time
    -   = Halves the screen refresh time
    0   = Reset peak counts to zero (peak highlight with ">")
    1   = Top Processes mode 1 Nice, Priority, Status
    3   = Top Processes mode 3 CPU, Memory, Faults
    4   = Top Processes mode 4 as 3 but order by memory
    5   = Top Processes mode 5 as 3 but order by I/O (if root user)
    6   = Highlights 60% row on Long Term CPU view
    7   = Highlights 70% row on Long Term CPU view
    8   = Highlights 80% row on Long Term CPU view
    9   = Highlights 90% row on Long Term CPU view
    .   = Minimum mode i.e. only busy disks and processes shown
    space = Refresh screen now

Interactive Start-up 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=cmdrtn

Other items for Interactive and Data Collection mode:
    a) 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
Other items for Data Collection mode:
    b) To you want to stop nmon use: kill -USR2 <nmon-pid>
    c) Use -p and nmon outputs the background process pid
    d) If you want to pipe nmon output to other commands use a FIFO:
        mkfifo /tmp/mypipe
        nmon -F /tmp/mypipe &
        tail -f /tmp/mypipe
    e) If nmon fails please report it with:
       1) nmon version like: 16d
       2) the output of: cd /proc; cat cpuinfo meminfo partitions stat vmstat
       3) some clue of what you were doing
       4) I may ask you to run the debug version or collect data files
    f) If box & line characters are letters then check: terminal emulator & $TERM
    g) External Data Collectors - nmon will execute a command or script at each snapshot time
       They must output to a different file which is merge afterwards with the nmon output
       Set the following shell variables:
        NMON_START  = script to generate CVS Header test line explaining the columns
             Generate: TabName,DataDescription,Column_name_and_units,Column_name_and_units ... 
        NMON_SNAP   = script for each snapshots data, the parameter is the T0000 snapshot number
             Generate: TabName,T00NN,Data,Data,Data ...
        NMON_END    = script to clean up or finalise the data
        NMON_ONE_IN = call NMON_START less often (if it is heavy in CPU terms)
        Once capture done: cat nmon-file data-file >merged-file ; ready for Analyser or other tools
        The nmon Analyser will automatically do its best to graph the data on a new Tab sheet

    Developer: Nigel Griffiths     See http://nmon.sourceforge.net
    Feedback welcome - On the current release only
    No warranty given or implied. Copyright GPLv3

 運行帶 -f 標志的 nmon 命令。

nmon -f -s 30 -c 100

[root@lamw /home/lam7/nmon]# nmon -f -s 36 -c 100

 

-f 表示生成的數據文件名中有時間;

-t 輸出中包括占用率較高的進程;

-s 36 表示每 36 秒采集一次數據;

-c 100 表示采集 100 次,36s*100=3600秒;

采集60分鍾數據,這樣運行一次這個程序就會生成一個采集 60分鍾數據的文件。該行命令將在當前目錄中創建輸出文件,其名稱為:<hostname>_date_time.nmon", hostname" 是這台主機的主機名。

在采集當中也可以通過命令

ps -ef | grep nmon 查看采集數據的進程 

[root@lamw /home/lam7/nmon]# ps -ef | grep nmon

60分鍾后 再次執行 此命令可以發現 進程已結束

 

在我們當前目錄下可以查看到 以 ****_170323_1102.nmon 命名的文件 “***”為主機名稱

我們通過more命令后發現都是我們看不懂的一些文本,這就需要我們把其轉化成我們能看懂的excel格式的文件。首先我們把****_170323_1102.nmon文件導出到我們的windows本地。然后通過nmon Analyser 去生成報告CSV文件

 

下載安裝 nmon Analyser

 

https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Power+Systems/page/nmon_analyser

 

 

下載解壓后  發現 一個是NA_UserGuide v51_2.docx的說明word格式的說明文檔,另一個是nmon analyser v51_2.xlsm格式的nmon analyse文件。

打開nmon analyser v51_2.xlsm  導入從linux中導出的 ****_170323_1102.nmon文件,生成報告excel文檔

如果是用WPS打開nmon analyser v51_2.xlsm的,會提示安裝 宏 ,wps是不帶宏的,安裝 宏 之后 調整Excel宏安全性:工具--宏--安全性----低

 

 

 

 

 

 

 可以切換 展示的圖片格式   查看所監控的數據信息

橙色  :系列"IO/sec"

藍色  : 系列"CPU%"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM