一、先看幫助信息
- [root@linux nmon]# ./nmon.sh -h
- Hint: nmon.sh [-h] [-s <seconds>] [-c <count>] [-f -d <disks> -t -r <name>] [-x]
- -h 查看完整的說明信息,有兩種模式:a、命令行交互式模式 (h) b、對於數據收集模式 (-f)
- -f 電子表格的輸出格式 [注意:默認 -s300 -c288] 可選 (300秒*288次=86400秒=60*60*24=1天)
- -s <seconds> 刷新屏幕頻率的時間 [默認 2]
- -c <number> 刷新屏幕的次數 [默認 1000000]
- -d <disks> to increase the number of disks [default 256]
- -t spreadsheet includes top processes
- -x capacity planning (每15分鐘1天 = -fdt -s 900 -c 96)
- 版本 - nmon 14g
- 對於命令行交互式模式
- -s <seconds> 刷新屏幕頻率的時間 [默認 2]
- -c <number> 刷新屏幕的次數 [默認 1000000]
- -g <filename> User Defined Disk Groups [hit g to show them]
- - file = on each line: group_name <disks list> space separated
- - like: database sdb sdc sdd sde
- - upto 64 disk groups, 512 disks per line
- - disks can appear more than once and in many groups
- -b 命令行交互模式的界面是黑色和白色 [默認的顏色]
- 例如: nmon.sh -s 1 -c 100 (說明:在命令行交互模式下,每秒鐘刷新一次屏幕,總共採集100次)
- 對於數據收集模式 = 電子表格格式 (逗號分隔值)
- Note: use only one of f,F,z,x or X and make it the first argument
- -f 電子表格輸出格式 [注意: default -s300 -c288]
- 輸出文件是 <hostname>_YYYYMMDD_HHMM.nmon
- -F <filename> 等同於 -f 但是使用用戶提供的文件名
- -r <runname> 用於電子表格文件 [default hostname]
- -t include top processes in the output
- -T as -t plus saves command line arguments in UARG section
- -s <seconds> 採集數據的時間
- -c <number> 採集數據的次數
- -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) - see BBBG & DG lines
- -N include NFS Network File System
- -I <percent> Include process & disks busy threshold (default 0.1)
- don't save or show proc/disk using less than this percent
- -m <directory> 生成的數據文件的路徑
- 例如:在30秒的時間間隔收集的top procs,持續1小時
- nmon.sh -f -t -r Test1 -s30 -c120
- To load into a spreadsheet:
- sort -A *nmon >stats.csv
- transfer the stats.csv file to your PC
- Start spreadsheet & then Open type=comma-separated-value ASCII file
- The nmon analyser or consolidator does not need the file sorted.
- Capacity planning mode - use cron to run each day
- -x sensible spreadsheet output for CP = one day
- 每15分鐘1天 ( i.e. -ft -s 900 -c 96)
- -X sensible spreadsheet output for CP = busy hour
- 每30秒1小時 ( i.e. -ft -s 30 -c 120)
- 交互模式命令
- key --- Toggles to control what is displayed ---
- h = 聯機幫助信息
- r = 機器類型,機器名,緩存信息和OS版本+LPAR
- c = CPU處理器統計條形圖
- l = 條形圖長期CPU(超過75個快照)
- m = 內存統計
- L = 巨大的內存頁面統計
- V = 虛擬內存和交換統計
- k = 內核內部統計
- n = 網絡統計和錯誤
- N = NFS網絡文件系統
- d = 磁盤I/O圖
- D = 磁盤I/O統計
- o = 磁盤I/O映射(每個磁盤上的一個字符顯示它是多麼繁忙)
- j = 文件系統
- t = 頂級進程統計使用1,3,4,5來選擇數據及順序
- u = 頂級進程命令的詳細信息
- v = 詳細簡單的檢查 - OK/Warn(警告)/Danger(危險)
- b = 黑白模式(或使用- b選項)
- . = 最小模式,即只顯示繁忙的磁盤和進程
- key --- Other Controls ---
- + = 雙屏幕刷新時間
- - = 一半的屏幕刷新時間
- q = 退出 (also x, e or control-C)
- 0 = 零峯計數復位 (峯值 = ">")
- space = 立即刷新屏幕
- 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: 14g
- 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
- Developer Nigel Griffiths
- Feedback welcome - on the current release only and state exactly the problem
- No warranty given or implied.
- root@linux nmon]# ./nmon.sh
- +nmon-14g------[H for help]---Hostname=linux--------Refresh= 2secs ---04:22.50-----------------------------------------------------------------------------------------------------------------+
- | |
- | ------------------------------ 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 |
- |-----------------------------------------------------------------------------------------------------------------------
- +nmon-14g------[H for help]---Hostname=linux--------Refresh= 2secs ---04:27.49-----------------------------------------------------------------------------------------------------------------+
- | HELP ------------------------------------------------------------------------------------------------------------------------------------------------ |
- | key --- statistics which toggle on/off --- |
- | h = This help information |
- | r = RS6000/pSeries CPU/cache/OS/kernel/hostname details + LPAR |
- | t = Top Process Stats 1=basic 3=CPU |
- | u = shows command arguments (hit twice to refresh) |
- | c = CPU by processor l = longer term CPU averages |
- | m = Memory & Swap stats L=Huge j = JFS Usage Stats |
- | n = Network stats N = NFS |
- | d = Disk I/O Graphs D=Stats o = Disks %Busy Map |
- | k = Kernel stats & loadavg V = Virtual Memory |
- | g = User Defined Disk Groups [start nmon with -g <filename>] |
- | v = Verbose Simple Checks - OK/Warnings/Danger |
- | b = black & white mode |
- | --- controls --- |
- | + and - = double or half the screen refresh time |
- | q = quit space = refresh screen now |
- | . = Minimum Mode =display only busy disks and processes |
- | 0 = reset peak counts to zero (peak = ">") |
- | Developer Nigel Griffiths see http://nmon.sourceforge.net |
- |-----------------------------------------------------------------------------------------------
- Linux and Processor Details ------------------------------------------------------------------------------------------------------------------------- |
- | Linux: Linux version 2.6.18-164.el5 ([email protected]) |
- | Build: (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) |
- | Release : 2.6.18-164.el5 |
- | Version : #1 SMP Tue Aug 18 15:51:54 EDT 2009 |
- | cpuinfo: model name : Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz |
- | cpuinfo: vendor_id : GenuineIntel |
- | cpuinfo: cpu MHz : 2093.260 |
- | cpuinfo: bogomips : 4186.52 |
- | # of CPUs: 1 --1顆cpu |
- | Machine : i686 |
- | Nodename : linux --hostname |
- | /etc/*ease[1]: Red Hat Enterprise Linux Server release 5.4 (Tikanga) --操作系統版本 |
- | /etc/*ease[2]: (null) |
- | /etc/*ease[3]: (null) |
- | /etc/*ease[4]: (null) |
- | lsb_release: Distributor ID: RedHatEnterpriseServer |
- | lsb_release: Description: Red Hat Enterprise Linux Server release 5.4 (Tikanga) |
- | lsb_release: Release: 5.4 |
- | lsb_release: Codename: Tikanga |
- +---------Warning: Some Statistics may not shown--------------------------------
在這裏看見一些主機和操作系統的信息,再敲一次 r 就會取消顯示了,然後輸入 t (頂級進程統計使用1,3,4,5來選擇數據及順序),然後再按數字 5 :
- Top Processes Procs=85 mode=5 (1=Basic, 3=Perf 4=Size 5=I/O)---------------------------------------------------------------------------------------------------------------------------------|
- | PID %CPU Size Res Res Res Res Shared Faults Command |
- | Used KB Set Text Data Lib KB Min Maj |
- | 4050 0.5 12748 10548 108 10896 0 832 84 0 nmon.sh |
- | 1 0.0 2072 624 32 280 0 532 0 0 init |
- | 2 0.0 0 0 0 0 0 0 0 0 migration/0 |
- | 3 0.0 0 0 0 0 0 0 0 0 ksoftirqd/0 |
- | 4 0.0 0 0 0 0 0 0 0 0 watchdog/0 |
- | 5 0.0 0 0 0 0 0 0 0 0 events/0 |
- | 6 0.0 0 0 0 0 0 0 0 0 khelper |
- | 7 0.0 0 0 0 0 0 0 0 0 kthread |
- | 10 0.0 0 0 0 0 0 0 0 0 kblockd/0 |
- | 11 0.0 0 0 0 0 0 0 0 0 kacpid |
- | 67 0.0 0 0 0 0 0 0 0 0 cqueue/0 |
- | 70 0.0 0 0 0 0 0 0 0 0 khubd |
- | 72 0.0 0 0 0 0 0 0 0 0 kseriod |
- | 136 0.0 0 0 0 0 0 0 0 0 pdflush |
- | 137 0.0 0 0 0 0 0 0 0 0 pdflush |
- | 138 0.0 0 0 0 0 0 0 0 0 kswapd0 |
- | 139 0.0 0 0 0 0 0 0 0 0 aio/0 |
- +---------Warning: Some Statistics may not shown----------------------------
- Top Processes Procs=85 mode=5 (1=Basic, 3=Perf 4=Size 5=I/O)---------------------------------------------------------------------------------------------------------------------------------|
- | PID %CPU ResSize Command Command |
- | Used KB |
- | 4050 1.0 10660 ./nmon.sh |
- | 1 0.0 624 init [3] |
- | 2 0.0 0 [migration/0] |
- | 3 0.0 0 [ksoftirqd/0] |
- | 4 0.0 0 [watchdog/0] |
- | 5 0.0 0 [events/0] |
- | 6 0.0 0 [khelper] |
- | 7 0.0 0 [kthread] |
- | 10 0.0 0 [kblockd/0] |
- | 11 0.0 0 [kacpid] |
- | 67 0.0 0 [cqueue/0] |
- | 70 0.0 0 [khubd] |
- | 72 0.0 0 [kseriod] |
- | 136 0.0 0 [pdflush] |
- | 137 0.0 0 [pdflush] |
- | 138 0.0 0 [kswapd0] |
- | 139 0.0 0 [aio/0] |
- +---------Warning: Some Statistics may not shown---------
以上信息都很直觀,我就不在多說了,接着看 c (CPU處理器統計條形圖):
- CPU Utilisation ------------------------------------------------------------------------------------------------------------------------------------- |
- |---------------------------+-------------------------------------------------+ |
- |CPU User% Sys% Wait% Idle|0 |25 |50 |75 100| |
- | 1 0.0 0.0 0.0 100.0| > | |
- |---------------------------+-------------------------------------------------+ |
- |---------------------------------------------------------------------------------
從上面可以看見系統非常閒(Idle=100%),其中“>”代表的是系統最高cpu的使用峯值,如果按數字0就會重置峯值爲0了,接着看 l (條形圖長期CPU):
- 100%-| | |
- | 95%-| | |
- | 90%-| | |
- | 85%-| | |
- | 80%-| | |
- | 75%-| | |
- | 70%-| | |
- | 65%-| | |
- | 60%-| | |
- | 55%-| | |
- | 50%-| | |
- | 45%-| | |
- | 40%-| | |
- | 35%-| | |
- | 30%-| | |
- | 25%-| | |
- | 20%-| | |
- | 15%-| | |
- | 10%-| | |
- +---------Warning: Some Statistics may not shown-
- Memory Stats ---------------------------------------------------------------------------------------------------------------------------------------- |
- | RAM High Low Swap Page Size=4 KB |
- | Total MB 503.3 0.0 503.3 1027.6 |
- | Free MB 192.3 0.0 192.3 1027.6 |
- | Free Percent 38.2% 0.0% 38.2% 100.0% |
- | MB MB MB |
- | Cached= 200.6 Active= 107.4 |
- | Buffers= 46.4 Swapcached= 0.0 Inactive = 169.7 |
- | Dirty = 0.2 Writeback = 0.0 Mapped = 9.5 |
- | Slab = 26.8 Commit_AS = 130.0 PageTables= 1.3
從上面可以看見swap還100%沒有使用,物理內存ram空閒38.2%,接着看 L (巨大的內存頁面統計):
- arge (Huge) Page Stats ----------------------------------------------------------------------------------------------------------------------------- |
- | There are no Huge Pages |
- | - see /proc/meminfo |
- |
- Network I/O ----------------------------------------------------------------------------------------------------------------------------------------- |
- |I/F Name Recv=KB/s Trans=KB/s packin packout insize outsize Peak->Recv Trans |
- | lo 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.2 |
- | eth0 0.0 0.1 0.5 0.5 60.0 218.0 52.4 99.0 |
- | sit0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 |
- | Network Error Counters ------------------------------------------------------------------------------------------------------------------------------ |
- |I/F Name iErrors iDrop iOverrun iFrame oErrors oDrop oOverrun oCarrier oColls |
- | lo 0 0 0 0 0 0 0 0 0 |
- | eth0 0 0 0 0 0 0 0 0 0 |
- | sit0 0 0 0 0 0 0 0 0 0 |
- |-------------------------------------------------------------------------------------
接着看 N (NFS網絡文件系統):
- | Network Filesystem (NFS) I/O Operations per second -------------------------------------------------------------------------------------------------- |
- | Version 2 Client Server Version 3 Client Server |
- | null 0.0 0.0 null 0.0 0.0 |
- | getattr 0.0 0.0 getattr 0.0 0.0 |
- | setattr 0.0 0.0 setattr 0.0 0.0 |
- | root 0.0 0.0 lookup 0.0 0.0 |
- | lookup 0.0 0.0 access 0.0 0.0 |
- | readlink 0.0 0.0 readlink 0.0 0.0 |
- | read 0.0 0.0 read 0.0 0.0 |
- | wrcache 0.0 0.0 write 0.0 0.0 |
- | write 0.0 0.0 create 0.0 0.0 |
- | create 0.0 0.0 mkdir 0.0 0.0 |
- | remove 0.0 0.0 symlink 0.0 0.0 |
- | rename 0.0 0.0 mknod 0.0 0.0 |
- | link 0.0 0.0 remove 0.0 0.0 |
- | symlink 0.0 0.0 rmdir 0.0 0.0 |
- | mkdir 0.0 0.0 rename 0.0 0.0 |
- | rmdir 0.0 0.0 link 0.0 0.0 |
- | readdir 0.0 0.0 readdir 0.0 0.0 |
- | fsstat 0.0 0.0 readdirplus 0.0 0.0 |
- +---------Warning: Some Statistics may not shown----------------------------------------
接着看 d (磁盤I/O圖):
- | Disk I/O --/proc/diskstats----mostly in KB/s-----Warning:contains duplicates------------------------------------------------------------------------- |
- |DiskName Busy Read WriteKB|0 |25 |50 |75 100| |
- |sda 0% 0.0 0.0|> | |
- |sda1 0% 0.0 0.0|> | |
- |sda2 0% 0.0 0.0|> | |
- |sda3 0% 0.0 0.0|> | |
- |Totals Read-MB/s=0.0 Writes-MB/s=0.0 Transfers/sec=0.0 |
- |--------------------------------------------------------------
接着看 D (磁盤I/O統計):
- Disk I/O --/proc/diskstats----mostly in KB/s-----Warning:contains duplicates------------------------------------------------------------------------- |
- |DiskName Busy Read Write Xfers Size Peak% Peak-RW InFlight |
- |sda 0% 0.0 0.0KB/s 0.0 0.0KB 0% 8.0KB/s 0 | |
- |sda1 0% 0.0 0.0KB/s 0.0 0.0KB 0% 0.0KB/s 0 | |
- |sda2 0% 0.0 0.0KB/s 0.0 0.0KB 0% 0.0KB/s 0 | |
- |sda3 0% 0.0 0.0KB/s 0.0 0.0KB 0% 8.0KB/s 0 | |
- |Totals Read-MB/s=0.0 Writes-MB/s=0.0 Transfers/sec=0.0 |
- |------------------------------------------------------
接着看 o (磁盤I/O映射):
- | Disk %Busy Map --Key: @=90 #=80 X=70 8=60 O=50 0=40 o=30 +=20 -=10 .=5 _=0%-------------------------------------------------------------------------- |
- | Disk No. 1 2 3 4 5 6 |
- |Disks=4 0123456789012345678901234567890123456789012345678901234567890123 |
- |disk 0 to 63 ____ |
- |---------------
接着看 k (內核內部統計)
- | Kernel Stats ---------------------------------------------------------------------------------------------------------------------------------------- |
- | RunQueue 1 Load Average CPU use since boot time |
- | ContextSwitch 30228.5 1 mins 0.00 Uptime Days= 0 Hours= 2 Mins=29 |
- | Forks 25.9 5 mins 0.00 Idle Days= 0 Hours= 2 Mins=28 |
- | Interrupts 738415.7 15 mins 0.00 Average CPU use= 0.98% |
- |----------------------------------------------------------------------------------
接着看 V (虛擬內存和交換統計):
- | Virtual-Memory -------------------------------------------------------------------------------------------------------------------------------------- |
- |nr_dirty = 0 pgpgin = 0 High Normal DMA |
- |nr_writeback= 0 pgpgout = 0 alloc 0 0 0 |
- |nr_unstable = 0 pgpswpin = 0 refill 0 0 0 |
- |nr_table_pgs= 330 pgpswpout = 0 steal 0 0 0 |
- |nr_mapped = 2438 pgfree = 0 scan_kswapd 0 0 0 |
- |nr_slab = 6852 pgactivate = 0 scan_direct 0 0 0 |
- | pgdeactivate= 0 |
- |allocstall = 0 pgfault = 7 kswapd_steal = 0 |
- |pageoutrun = 0 pgmajfault = 0 kswapd_inodesteal= 0 |
- |slabs_scanned= 0 pgrotated = 0 pginodesteal = 0 |
- |-----------------------------------------------------------------
- | Verbose Mode ---------------------------------------------------------------------------------------------------------------------------------------- |
- | Code Resource Stats Now Warn Danger |
- | OK -> CPU %busy 0.0% >80% >90% |
- | OK -> Top Disk %busy 0.0% >40% >60% |
- | |
- | |
- | HELP ------------
這裏顯示了cpu和disk的一個診斷信息,Warn(警告)/Danger(危險),可以看見cpu大於80%就是警告,大於90%就是危險,disk同理如下。