Linux atop 監控系統狀態

 

atop是一個功能很是強大的linux服務器監控工具,它的數據採集主要包括:CPU、內存、磁盤、網絡、進程等,而且內容很是的詳細,特別是當那一部分存在壓力它會以特殊的顏色進行展現,若是顏色是紅色那麼說明已經很是嚴重了。php

 

 注意:全部的信息都是反映過去10S的狀態信息linux

使用ios

atop工具安裝好後在運行命令atop就能彈出監控界面git

 接下來咱們就來詳細看看每行參數意義。github

atop:改行列出了服務器的host、當前時間、信息收集的頻率web

PRC:該列展現整個系統的性能情況;緩存

  1. sys:過去10s全部的進程在內核態運行的時間總和
  2. usr:過去10s全部的進程在用戶態的運行時間總和
  3. #proc:進程總數
  4. #trun:過去10s轉換的進程數
  5. #zombie:過去10s僵死進程的數量
  6. #exit:在10s採樣週期期間退出的進程數量

CPU: cpu列展現了服務器的CPU總體的一個狀態信息,包括內核和用戶所佔的比例、處理中斷所佔的比例、CPU的處於空閒下比例(這裏是100%*cpu核心數,CPU有時候也會由於因爲磁盤性能問題出現等待的空閒)服務器

  1. sys:cpu在處理進程時處於內核態的時間所佔的比例
  2. usr:cpu在處理進程時處於用戶態的時間所佔的比例
  3. irq:cpu在處理進程的中斷請求所佔的實際比例
  4. idle:cpu處於空閒狀態下的時間比例(除了自己空閒,還有好比等待磁盤io的狀況下也會處於空閒狀態)

cpu:每一個核心的狀態信息,和總的CPU信息同樣,每列加起來的總和就是總的CPU的狀態信息。網絡

CPL:cpl也反應了服務器總體的性能,展現信息包括進程等待隊列數,分別從過去1分鐘、5分鐘、15分鐘的採樣信息。app

  1. avg1:過去1分鐘進程等待隊列數
  2. avg5:過去5分鐘進程等待隊列數
  3. avg15:過去15分鐘進程等待隊列數
  4. csw(context swapping):上下文交換次數
  5. intr(interrupt):中斷髮生的次數
  6. numcpu:cpu的核心數

mem:該列主要展現內存的使用信息。

  1. tot:物理內存總量
  2. free:空閒內存的大小(不能單單從這個字段就判斷內存不足,還須要參考free -m中的-/+ buffers/cache:free由於這塊的內容隨時就能夠拿過來使用,還能夠從是否有使用Swap來判斷是否內存不足)
  3. cache:用於頁緩存的內存大小
  4. dirty:內存中的髒頁大小
  5. buff:用於文件緩存的內存大小
  6. slab:系統內核佔用的內存大小

SWP:交換空間使用狀況

  1. tot:交換空間總量
  2. free:交換空間剩餘空間總量

PAG列:虛擬內存分頁狀況

  1. swin:換入內存頁數
  2. swout:換出內存頁數

LVM/DSK:每一個分區信息以一列來進行展現

  1. busy:磁盤忙時所佔比例
  2. read、KiB/r 、MBr/s:每秒讀的請求數和請求的kb、mb數
  3. write、KiB/w 、MBr/w:每秒寫的請求數和請求的kb、mb數
  4. avq:磁盤平均隊列長度(根據實際的監控該列好像是磁盤平均請求數avgrq)
  5. avio:磁盤的平均io時間

 

NET:展現了傳輸層(TCP/UDP)、網絡層(ip)、網絡接口的網絡傳輸信息。

transport:傳輸層(TCP/UDP)的數據輸入輸出的展現,例如在服務器的內部進程之間的數據傳輸就是在傳輸層展現,覺得還不須要往下經過網絡進行傳輸。

network:網絡層(ip)的數據輸入輸出的展現;

eth0:默認的網絡接口的數據輸入輸出的展現,也就是經過etho的ip的數據傳輸的展現,

  1. sp:網卡的帶寬(1000M)
  2. pcki:傳入的數據包的大小
  3. pcko:傳出的數據包的大小
  4. si:每秒傳入的數據大小
  5. so:每秒傳出的數據大小
  6. coll(collisions):每秒的衝突數
  7. mlti(MULTICAST):每秒的多路廣播的數量
  8. erri/erro:每秒輸入輸出的錯誤數
  9. drpi/drpo:每秒的輸入輸出的丟包數

lo:經過127.0.0.1網絡接口的數據傳輸的數據展現,參數和上面的eth0是同樣的

 

進程列

進程列展現了每一個進程在過去10S內的數據

m模式:內存狀態模式

SYSCPU:過去10s內進程處於內核模式佔用的CPU時間

USRCPU:過去10S進程處於用戶模式佔用的CPU時間

VSIZE:過去10S進程佔用的虛擬空間大小

RSIZE:過去10S進程佔用的內存空間大小

PSIZE:過去10S進程佔用的頁大小

VGROW:過去10S進程增加的虛擬空間大小

RGROW:過去10S進程增加的內存大小

SWAPSZ:過去10S進程使用交換空間的大小。

MEM:過去10S進程佔用內存百分比

d模式:磁盤狀態模式

RDDSK:過去10S進程讀磁盤的數據量
WRDSK:過去10S進程寫磁盤的數據量
DSK:過去10S進程所佔磁盤的百分比
CMD:進程名 

p模式:進程狀態模式,同一個名稱的進程顯示一列,根據進程名進行分組顯示

NPROCS:相同名稱的進程數量

其它的參數上面已經有列出

v模式:線程狀態模式

u模式:用戶模式

根據用戶進行分組顯示

g模式:標準模式

s:進程當前的狀態,包括:s(sleeping),R(runing)等

atop的相關文件

/etc/atop:目錄保存的是atop的配置文件
/etc/rc.d/init.d/atop:atop的啓動文件
/etc/cron.d/atop:atop的定時任務文件,默認是天天0點開始
/var/log/atop:atop日誌文件,默認是天天0點開始會產生當天的一個日誌文件,而後能夠經過atop -r file 查看信息,可是沒有找到自動播放的的功能,只能經過輸入b顯示一個指定的時間的信息,能夠寫個循環來實現
/usr/bin/atop:atop命令目錄

 

atop -r atop_20160510 -b 13:00 -e 17:00 

atop產生的日誌文件信息是10分鐘一個採樣週期進行記錄,能夠經過修改/etc/atop/atop.daily文件進行修改。

 

atop的其它參數:

 
Usage: atop [-flags] [interval [samples]]
        or
Usage: atop -w  file  [-S] [-a] [interval [samples]]
       atop -r [file] [-b hh:mm] [-e hh:mm] [-flags]

    generic flags:
      -a  show or log all processes (i.s.o. active processes only)
      -R  calculate proportional set size (PSS) per process
      -P  generate parseable output for specified label(s)
      -L  alternate line length (default 80) in case of non-screen output
      -f  show fixed number of lines with system statistics
      -F  suppress sorting of system resources
      -G  suppress exited processes in output
      -l  show limited number of lines for certain resources
      -y  show individual threads
      -1  show average-per-second i.s.o. total values

      -x  no colors in case of high occupation
      -g  show general process-info (default)
      -m  show memory-related process-info
      -d  show disk-related process-info
      -n  show network-related process-info
      -s  show scheduling-related process-info
      -v  show various process-info (ppid, user/group, date/time)
      -c  show command line per process
      -o  show own defined process-info
      -u  show cumulated process-info per user
      -p  show cumulated process-info per program (i.e. same name)

      -C  sort processes in order of cpu-consumption (default)
      -M  sort processes in order of memory-consumption
      -D  sort processes in order of disk-activity
      -N  sort processes in order of network-activity
      -A  sort processes in order of most active resource (auto mode)

    specific flags for raw logfiles:
      -w  write raw data to   file (compressed)
      -r  read  raw data from file (compressed)
          special file: y[y...] for yesterday (repeated)
      -S  finish atop automatically before midnight (i.s.o. #samples)
      -b  begin showing data from specified time
      -e  finish showing data after specified time
 

下載地址:http://www.atoptool.nl/downloadatop.php

總結

 在atop的展現頁面也能夠輸入m(內存)、p(進程)、u(用戶)、d(磁盤)、c(進程運行的代碼)、v(線程) 進行頁面切換。

 

 

 

 

 

 

We’re all familiar with top, a real-time system monitor. Some prefer htop and previously I mentioned iotop for disk read/write monitoring. Lets looks at another popular tool for Linux server performance analysisatop.

atop - AT Computing's System & Process Monitor

Advantages of atop

Atop is a ASCII full-screen performance monitor which can log and report the activity of all server processes. One feature I really like is that atop will stay active in the background for long-term server analysis (up to 28 days by default). Other advantages include:

  • Shows resource usage of ALL processes, even those that are closed/completed.
  • Monitors threads within processes & ignores processes that are unused.
  • Accumulates resource usage for all processes and users with the same name.
  • Highlights critical resources using colors (red).
  • Will add or remove columns as the size of the display window changes.
  • Includes disk I/O and network utilization.
  • Uses netatop kernel module to monitor TCP & UDP and network bandwidth.

Once atop is launched, by default it will show system activity for CPU, memory, swap, disks and network in 10 second intervals. In addition, for each process and thread you can analyse CPU utilization, memory consumption, disk I/O, priority, username, state, and even exit codes.

Install atop on RHEL/CentOS/Fedora Linux

First install and enable EPEL (Extra Packages for Enterprise Linux) repo. See: RedHat solution #308983.

yum install atop

Install atop on Debian/Ubuntu Linux

apt-get install atop

Once installed on any distro, you can launch it similar to top using:

atop

Guide on using atop system & process Monitor

A good place to start would be to read the man pages:

man atop

Other useful commands:

Launch with average-per-second total values:

atop -1

Launch with active processes only:

atop -a

Launch with command line per process

atop -c

Launch with disk info

atop -d

Launch with memory info

atop -m

Launch with network info

atop -n

Launch with scheduling info

atop -s

Launch with various info (ppid, user, time)

atop -v

Launch with individual threads

atop -y

Once atop is running, press the following shortcut keys to sort processes:

  • a – sort in order of most active resource.
  • c – revert to sorting by cpu consumption (default).
  • d – sort in order of disk activity.
  • m – sort in order of memory usage
  • n – sort in order of network activity

Guide to reading atop reports/logs

By default after install the atop daemon writes snapshots to a compressed log file (eg. /var/log/atop/atop_20140813). These log files can be read using:

atop -r /full/path/to/atop/log/file

Once you open a log file (eg. atop -r /var/log/atop/atop_20140813) then use t to go forward in 10 minute intervals and T to go back. You can analyse specific times by pressing b then entering the time. The above shortcut keys also work in this mode… a, c, d, m,n.

You can use shortcuts with atopsar. For example, using the flag 「-c 30 5」 with atopsar will generate a report for current CPU utilization for 5 minutes (ten times with intervals of 30 seconds):

atopsar -c 30 5

Using the flag -A with return all available reports.

atopsar -A

But you can limit this to a specific time window using beginning 「-b」 and end 「-e」 flags:

atopsar -A -b 11:00 -e 11:15

atop: http://www.atoptool.nl/

Other popular command line Linux server performance analysis tools

tophtopnmonnet-toolsiptrafcollectlglancesiostat and vmstat.

相關文章
相關標籤/搜索