atop是一個功能非常強大的linux服務器監控工具,它的數據采集主要包括:CPU、內存、磁盤、網絡、進程等,並且內容非常的詳細,特別是當那一部分存在壓力它會以特殊的顏色進行展示,如果顏色是紅色那么說明已經非常嚴重了。
注意:所有的信息都是反映過去10S的狀態信息
使用
atop工具安裝好后在運行命令atop就能彈出監控界面
接下來我們就來詳細看看每行參數意義。
atop:改行列出了服務器的host、當前時間、信息收集的頻率
PRC:該列展示整個系統的性能狀況;
- sys:過去10s所有的進程在內核態運行的時間總和
- usr:過去10s所有的進程在用戶態的運行時間總和
- #proc:進程總數
- #trun:過去10s轉換的進程數
- #zombie:過去10s僵死進程的數量
- #exit:在10s采樣周期期間退出的進程數量
CPU: cpu列展示了服務器的CPU整體的一個狀態信息,包括內核和用戶所占的比例、處理中斷所占的比例、CPU的處於空閑下比例(這里是100%*cpu核心數,CPU有時候也會因為由於磁盤性能問題出現等待的空閑)
- sys:cpu在處理進程時處於內核態的時間所占的比例
- usr:cpu在處理進程時處於用戶態的時間所占的比例
- irq:cpu在處理進程的中斷請求所占的實際比例
- idle:cpu處於空閑狀態下的時間比例(除了本身空閑,還有比如等待磁盤io的情況下也會處於空閑狀態)
cpu:每個核心的狀態信息,和總的CPU信息一樣,每列加起來的總和就是總的CPU的狀態信息。
CPL:cpl也反應了服務器整體的性能,展示信息包括進程等待隊列數,分別從過去1分鍾、5分鍾、15分鍾的采樣信息。
- avg1:過去1分鍾進程等待隊列數
- avg5:過去5分鍾進程等待隊列數
- avg15:過去15分鍾進程等待隊列數
- csw(context swapping):上下文交換次數
- intr(interrupt):中斷發生的次數
- numcpu:cpu的核心數
mem:該列主要展示內存的使用信息。
- tot:物理內存總量
- free:空閑內存的大小(不能單單從這個字段就判斷內存不足,還需要參考free -m中的-/+ buffers/cache:free因為這塊的內容隨時就可以拿過來使用,還可以從是否有使用Swap來判斷是否內存不足)
- cache:用於頁緩存的內存大小
- dirty:內存中的臟頁大小
- buff:用於文件緩存的內存大小
- slab:系統內核占用的內存大小
SWP:交換空間使用情況
- tot:交換空間總量
- free:交換空間剩余空間總量
PAG列:虛擬內存分頁情況
- swin:換入內存頁數
- swout:換出內存頁數
LVM/DSK:每個分區信息以一列來進行展示
- busy:磁盤忙時所占比例
- read、KiB/r 、MBr/s:每秒讀的請求數和請求的kb、mb數
- write、KiB/w 、MBr/w:每秒寫的請求數和請求的kb、mb數
- avq:磁盤平均隊列長度(根據實際的監控該列好像是磁盤平均請求數avgrq)
- avio:磁盤的平均io時間
NET:展示了傳輸層(TCP/UDP)、網絡層(ip)、網絡接口的網絡傳輸信息。
transport:傳輸層(TCP/UDP)的數據輸入輸出的展示,例如在服務器的內部進程之間的數據傳輸就是在傳輸層展示,以為還不需要往下通過網絡進行傳輸。
network:網絡層(ip)的數據輸入輸出的展示;
eth0:默認的網絡接口的數據輸入輸出的展示,也就是通過etho的ip的數據傳輸的展示,
- sp:網卡的帶寬(1000M)
- pcki:傳入的數據包的大小
- pcko:傳出的數據包的大小
- si:每秒傳入的數據大小
- so:每秒傳出的數據大小
- coll(collisions):每秒的沖突數
- mlti(MULTICAST):每秒的多路廣播的數量
- erri/erro:每秒輸入輸出的錯誤數
- 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進程讀磁盤的數據量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 analysis: atop.
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
top, htop, nmon, net-tools, iptraf, collectl, glances, iostat and vmstat.