自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Collectl:Linux系統(tǒng)監(jiān)控神器

系統(tǒng) Linux
Collectl作為一個輕量級的Linux監(jiān)控工具,在同類工具中是功能最全的。用戶可監(jiān)測不同的復雜系統(tǒng)矩陣值,并可保留數(shù)據(jù)以做之后的分析。不同于其他只用來監(jiān)測特定系統(tǒng)參數(shù)的工具,Collectl可以同時監(jiān)測不同的變量,并以合適的方式記錄它們。

[[111385]]

為使系統(tǒng)良好運轉(zhuǎn),Linux系統(tǒng)管理員經(jīng)常需要監(jiān)測cpu、內(nèi)存、磁盤、網(wǎng)絡(luò)等系統(tǒng)信息。Linux上已有iotop、top、free、htop、sar等豐富的常規(guī)工具來實現(xiàn)監(jiān)測功能。今天讓我們走進Collectl來了解這個集測試/監(jiān)控/分析系統(tǒng)性能為一體的Linux工具。

Collectl作為一個輕量級的監(jiān)控工具,在同類工具中是功能最全的。用戶可監(jiān)測不同的復雜系統(tǒng)矩陣值,并可保留數(shù)據(jù)以做之后的分析。不同于其他只用來監(jiān)測特定系統(tǒng)參數(shù)的工具,Collectl可以同時監(jiān)測不同的變量,并以合適的方式記錄它們。

摘自Collectl官網(wǎng) 

不同于或聚焦于一小組統(tǒng)計數(shù)據(jù)、采用唯一輸出方式,或采用迭代、作為守護進程運行的大部分監(jiān)測工具,collectl可以同時全部實現(xiàn)。用戶可選擇各種子系統(tǒng)中的任一系統(tǒng)來監(jiān)測包括內(nèi)存,CPU,磁盤,索引節(jié)點,無線帶寬,lustre,內(nèi)存,網(wǎng)絡(luò),網(wǎng)絡(luò)文件系統(tǒng),進程,二次型,slabs,套接口及TCP等信息。

深入學習前讓我們先看以下命令。

  1. $ collectl
  2. waiting for 1 second sample...
  3. #<--------CPU--------><----------Disks-----------><----------Network---------->
  4. #cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut
  5. 0 0 864 1772 0 0 0 0 0 1 0 0
  6. 5 2 1338 2734 0 0 8 2 0 0 0 1
  7. 1 0 1222 2647 0 0 92 3 0 2 0 1
  8. 1 0 763 1722 0 0 80 3 0 1 0 2

CPU使用率,磁盤輸入輸出和網(wǎng)絡(luò)活動以每秒為單位來加載。對可以理解這些數(shù)據(jù)的人來說這些信息很容易讀懂。這項列表在給定的時間間隔里會持續(xù)增加,并可直接形成一項文件跟蹤日志。collectl工具提供了各種命令來對這些數(shù)據(jù)進行記錄,查找及做其他處理。

安裝collectl工具

對Ubuntu/Debian用戶來說Collectl是默認資源,所以使用apt命令便可獲取。

  1. $ sudo apt-get install collectl

Fedora/CentOS用戶使用yum命令便可獲取。

  1. $ yum install collectl

使用

必要的了解 - Collectl子系統(tǒng)

子系統(tǒng)是可檢測到的不同系統(tǒng)資源類型。像CPU,內(nèi)存,帶寬等等都可構(gòu)成一個子系統(tǒng)。只運行collectl命令將以批處理模式輸出CPU,磁盤和網(wǎng)絡(luò)子系統(tǒng)信息,我們在上文已看到相關(guān)內(nèi)容。

從操作說明可以看到,Collectl可以識別以下子系統(tǒng)。

  1. 總計子系統(tǒng)
  2.  
  3. b - buddy info (內(nèi)存片段)
  4. c - CPU
  5. d - Disk
  6. f - NFS V3 Data
  7. i - Inode and File System
  8. j - Interrupts
  9. l - Lustre
  10. m - Memory
  11. n - Networks
  12. s - Sockets
  13. t - TCP
  14. x - Interconnect
  15. y - Slabs (system object caches)
  16.  
  17. 細節(jié)子系統(tǒng)
  18.  
  19. 這是一系列的詳細信息,大部分情況下都會由相應(yīng)的總計數(shù)據(jù)衍生出來。目前“環(huán)境變量”和“進程”2類沒有相應(yīng)的總計數(shù)據(jù)。如果有3個磁盤,選擇-sd,將只會看到3個磁盤組合出的單一信息。如果選擇-sD,將會分別顯示各磁盤信息。
  20.  
  21. C - CPU
  22. D - Disk
  23. E - Environmental data (fan, power, temp), via ipmitool
  24. F - NFS Data
  25. J - Interrupts
  26. L - Lustre OST detail OR client Filesystem detail
  27. M - Memory node data, which is also known as numa data
  28. N - Networks
  29. T - 65 TCP counters only available in plot format
  30. X - Interconnect
  31. Y - Slabs (system object caches)
  32. Z - Processes

使用“-s”來監(jiān)測特定的子系統(tǒng)并向其添加子系統(tǒng)的識別項。現(xiàn)在讓我們舉幾個例子。

1. 監(jiān)測cpu使用率

用“-sc”實現(xiàn)CPU總使用率的監(jiān)測

  1. $ collectl -sc 
  2. waiting for 1 second sample... 
  3. #<--------CPU--------> 
  4. #cpu sys inter  ctxsw  
  5.    3   0  1800   3729  
  6.    3   0  1767   3599 

使用“-C”觀察各個單獨的CPU使用情況。結(jié)果將會輸出多行,分別對應(yīng)一個CPU。

  1.    $ collectl -sC 
  2. waiting for 1 second sample... 
  3.   
  4. # SINGLE CPU STATISTICS 
  5.   
  6. #   Cpu  User Nice  Sys Wait IRQ  Soft Steal Idle 
  7.       0     3    0    0    0    0    0     0   96 
  8.       1     3    0    0    0    0    0     0   96 
  9.       2     2    0    0    0    0    0     0   97 
  10.       3     1    0    0    0    0    0     0   98 
  11.       0     2    0    0    0    0    0     0   97 
  12.       1     2    0    2    0    0    0     0   95 
  13.       2     1    0    0    0    0    0     0   98 
  14.       3     4    0    1    0    0    0     0   95 

如果需要,可以同時使用C和c來獲取單項CPU監(jiān)測數(shù)據(jù)和匯總數(shù)據(jù)。

2. 內(nèi)存監(jiān)測

使用m子系統(tǒng)查看內(nèi)存。

  1. $ collectl -sm 
  2. waiting for 1 second sample... 
  3. #<-----------Memory-----------> 
  4. #Free Buff Cach Inac Slab  Map  
  5.    2G 220M   1G   1G 210M   3G  
  6.    2G 220M   1G   1G 210M   3G  
  7.    2G 220M   1G   1G 210M   3G 

不難解釋。 M用來查看更多內(nèi)存的詳細信息。

  1. $ collectl -sM 
  2. waiting for 1 second sample... 
  3.   
  4. # MEMORY STATISTICS  
  5.   
  6. # Node    Total     Used     Free     Slab   Mapped     Anon   Locked    Inact Hit% 
  7.      0    7975M    5939M    2036M  215720K  372184K        0    6652K    1434M    0 
  8.      0    7975M    5939M    2036M  215720K  372072K        0    6652K    1433M    0 

這類似于免費報告嗎?

3. 查看磁盤使用情況

d和D可以查看磁盤使用的概況和詳細情況。

  1. $ collectl -sd 
  2. waiting for 1 second sample... 
  3. #<----------Disks-----------> 
  4. #KBRead  Reads KBWrit Writes  
  5.       4      1    136     24  
  6.       0      0     80     13 
  7.   
  8. $ collectl -sD 
  9. waiting for 1 second sample... 
  10.   
  11. # DISK STATISTICS (/sec) 
  12. #          <---------reads---------><---------writes---------><--------averages--------> Pct 
  13. #Name       KBytes Merged  IOs Size  KBytes Merged  IOs Size  RWSize  QLen  Wait SvcTim Util 
  14. sda              0      0    0    0       0      0    0    0       0     0     0      0    0 
  15. sda              0      0    0    0       0      0    0    0       0     0     0      0    0 
  16. sda              1      0    2    1      17      1    5    3       2     2     6      2    1 
  17. sda              0      0    0    0      92     11    5   18      18     1    12     12    5 

“--verbose”命令可以用來查看附加信息。和D命令不同,它將概況擴展,包含了更多信息。

  1. $ collectl -sd --verbose 

4. 同時報告多系統(tǒng)情況

如果想要同時得到CPU,內(nèi)存和磁盤報告,那么同時使用子命令組合來實現(xiàn)。

  1. $ collectl -scmd 
  2. waiting for 1 second sample... 
  3. #<--------CPU--------><-----------Memory-----------><----------Disks-----------> 
  4. #cpu sys inter  ctxsw Free Buff Cach Inac Slab  Map KBRead  Reads KBWrit Writes  
  5.    4   0  2187   4334   1G 221M   1G   1G 210M   3G      0      0      0      0  
  6.    3   0  1896   4065   1G 221M   1G   1G 210M   3G      0      0     20      5 

5. 顯示統(tǒng)計時間

若要將每行的監(jiān)測信息和時間一同顯示,使用T選項。通過在“-o”參數(shù)來指定。

  1. $ collectl -scmd -oT 
  2. waiting for 1 second sample... 
  3. #         <--------CPU--------><-----------Memory-----------><----------Disks-----------> 
  4. #Time     cpu sys inter  ctxsw Free Buff Cach Inac Slab  Map KBRead  Reads KBWrit Writes  
  5. 12:03:05    3   0  1961   4013   1G 225M   1G   1G 212M   3G      0      0      0      0  
  6. 12:03:06    3   0  1884   3810   1G 225M   1G   1G 212M   3G      0      0      0      0  
  7. 12:03:07    3   0  2011   4060   1G 225M   1G   1G 212M   3G      0      0      0      0 

使用“-oTm”可將時間換成毫秒顯示。

6. 改變樣本計數(shù)

collectl報告的每行都是一份快照或樣本,它通常設(shè)定定期間隔如1秒來取樣。i可用來設(shè)置時間間隔,c用來設(shè)置樣本計數(shù)。

  1. $ collectl -c1 -sm 
  2. waiting for 1 second sample... 
  3. #<-----------Memory-----------> 
  4. #Free Buff Cach Inac Slab  Map  
  5.    1G 261M   1G   1G 228M   3G 

使用i命令可改變更新時間間隔。

  1. $ collectl -sm -i2 
  2. waiting for 2 second sample... 
  3. #<-----------Memory-----------> 
  4. #Free Buff Cach Inac Slab  Map  
  5.    1G 261M   1G   1G 229M   3G 

上面的命令設(shè)定每2秒收集一次內(nèi)存信息。

7. 像iotop一樣使用collectl

top命令將collectl像iostat/top工具一樣進行智能統(tǒng)計。列表會持續(xù)更新,且可以使用不同字段實現(xiàn)排序。

  1. $ collectl --top iokb 

輸出如下:

  1. # TOP PROCESSES sorted by iokb (counters are /sec) 09:44:57 
  2. # PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command 
  3.  3104  enlighte 20  2683    3 S  938M   33M  0  0.00  0.00   0  00:09.16    0    4    0    0 /usr/bin/ktorrent  
  4.     1  root     20     0    0 S   26M    3M  2  0.00  0.00   0  00:01.30    0    0    0    0 /sbin/init  
  5.     2  root     20     0    0 S     0     0  3  0.00  0.00   0  00:00.00    0    0    0    0 kthreadd  
  6.     3  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.02    0    0    0    0 ksoftirqd/0  
  7.     4  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kworker/0:0  
  8.     5  root      0     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kworker/0:0H  
  9.     7  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.08    0    0    0    0 migration/0  
  10.     8  root     20     2    0 S     0     0  2  0.00  0.00   0  00:00.00    0    0    0    0 rcu_bh  
  11.     9  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 rcuob/0 

上面的輸出很像top命令,并且它以磁盤數(shù)量降序排列進程。

若只想顯示上面的5項進程,可用以下命令實現(xiàn)。

  1. $ collectl --top iokb,5 

若想學習上面的列表里哪些字段可以排序,使用如下命令:

  1. $ collectl --showtopopts 
  2.   
  3. 下面是應(yīng)用于進程或數(shù)據(jù)的最高排序類型列表。某些情況下你可能會使用某一字段進行排序,但它并非顯示的一部分。 
  4.   
  5. TOP PROCESS SORT FIELDS 
  6. 進程排序字段 
  7.   
  8. Memory 
  9.   vsz    virtual memory 
  10.   rss    resident (physical) memory 
  11.   
  12. Time 
  13.   syst   system time 
  14.   usrt   user time 
  15.   time   total time 
  16.   accum  accumulated time 
  17.   
  18. I/O 
  19.   rkb    KB read 
  20.   wkb    KB written 
  21.   iokb   total I/O KB 
  22.   
  23.   rkbc   KB read from pagecache 
  24.   wkbc   KB written to pagecache 
  25.   iokbc  total pagecacge I/O 
  26.   ioall  total I/O KB (iokb+iokbc) 
  27.   
  28.   rsys   read system calls 
  29.   wsys   write system calls 
  30.   iosys  total system calls 
  31.   
  32.   iocncl Cancelled write bytes 
  33.   
  34. Page Faults 
  35.   majf   major page faults 
  36.   minf   minor page faults 
  37.   flt    total page faults 
  38.   
  39. Context Switches 
  40.   vctx   volunary context switches 
  41.   nctx   non-voluntary context switches 
  42.   
  43. Miscellaneous (best when used with --procfilt) 
  44.   cpu    cpu number 
  45.   pid    process pid 
  46.   thread total process threads (not counting main) 
  47.   
  48. TOP SLAB SORT FIELDS 
  49.   
  50.   numobj    total number of slab objects 
  51.   actobj    active slab objects 
  52.   objsize   sizes of slab objects 
  53.   numslab   number of slabs 
  54.   objslab   number of objects in a slab 
  55.   totsize   total memory sizes taken by slabs 
  56.   totchg    change in memory sizes 
  57.   totpct    percent change in memory sizes 
  58.   name      slab names 

8. 像top一樣使用collectl

為使collectl像top,我們只需以CPU使用率排序輸出進程。

  1. $ collectl --top 

輸出如下:

  1. # TOP PROCESSES sorted by time (counters are /sec) 14:08:46 
  2. # PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command 
  3.  9471  enlighte 20  9102    0 R   63M   22M  3  0.03  0.10  13  00:00.81    0    0    0    3 /usr/bin/perl  
  4.  3076  enlighte 20  2683    2 S  521M   40M  2  0.00  0.03   3  00:55.14    0    0    0    2 /usr/bin/yakuake  
  5.  3877  enlighte 20  3356   41 S    1G  218M  1  0.00  0.03   3  10:10.50    0    0    0    0 /opt/google/chrome/chrome  
  6.  4625  enlighte 20  2895   36 S    1G  241M  2  0.00  0.02   2  08:24.39    0    0    0   12 /usr/lib/firefox/firefox  
  7.  5638  enlighte 20  3356    3 S    1G  265M  1  0.00  0.02   2  09:55.04    0    0    0    2 /opt/google/chrome/chrome  
  8.  1186  root     20  1152    4 S  502M   76M  0  0.00  0.01   1  03:02.96    0    0    0    0 /usr/bin/X  
  9.  1334  www-data 20  1329    0 S   87M    1M  2  0.00  0.01   1  00:00.85    0    0    0    0 nginx: 

上面的命令也可用于顯示子系統(tǒng)信息。

  1. $ collectl --top -scm 

9. 像ps一樣列出進程

為像ps命令一樣列出所有進程且沒有后續(xù)更新,用“c”命令讓其計數(shù)至1. $ collectl -c1 -sZ -i:1

上面的命令將會列出類似“ps -e”命令的所有進程。“procfilt”用于從所有進程中過濾出特定的進程信息。“procopts”用于指定另一組微調(diào)進程列表顯示的命令。

10. 像vmstat一樣使用collectl

Collectl有內(nèi)置命令來完成像vmstat一樣的功能。

  1. $ collectl --vmstat 
  2. waiting for 1 second sample... 
  3. #procs ---------------memory (KB)--------------- --swaps-- -----io---- --system-- ----cpu----- 
  4. # r  b   swpd   free   buff  cache  inact active   si   so    bi    bo   in    cs us sy  id wa 
  5.   1  0      0  1733M   242M  1922M  1137M   710M    0    0     0   108 1982  3918  2  0  95  1 
  6.   1  0      0  1733M   242M  1922M  1137M   710M    0    0     0     0 1906  3886  1  0  98  0 
  7.   1  0      0  1733M   242M  1922M  1137M   710M    0    0     0     0 1739  3480  3  0  96  0 

11. 子系統(tǒng)的詳細信息

下面的命令以一秒為間隔,統(tǒng)計5次CPU信息并和時間一起顯示出詳細信息(冗長)。

  1. $ collectl -sc -c5 -i1 --verbose -oT 
  2. waiting for 1 second sample... 
  3.   
  4. # CPU SUMMARY (INTR, CTXSW & PROC /sec) 
  5. #Time      User  Nice   Sys  Wait   IRQ  Soft Steal  Idle  CPUs  Intr  Ctxsw  Proc  RunQ   Run   Avg1  Avg5 Avg15 RunT BlkT 
  6. 14:22:10     11     0     0     0     0     0     0    87     4  1312   2691     0   866     1   0.78  0.86  0.78    1    0 
  7. 14:22:11     15     0     0     0     0     0     0    84     4  1283   2496     0   866     1   0.78  0.86  0.78    1    0 
  8. 14:22:12     17     0     0     0     0     0     0    82     4  1342   2658     0   866     0   0.78  0.86  0.78    0    0 
  9. 14:22:13     15     0     0     0     0     0     0    84     4  1241   2429     0   866     1   0.78  0.86  0.78    1    0 
  10. 14:22:14     11     0     0     0     0     0     0    88     4  1270   2488     0   866     0   0.80  0.87  0.78    0    0 

改變"-s"變量查看不同的子系統(tǒng)。

總結(jié)

本文的介紹不過是對collectl這個強大工具的一些淺見。本文本希望展示它有多靈活,其實通過以上的討論讓我們了解了包括記錄及回尋捕獲的數(shù)據(jù),以多種文件格式導出數(shù)據(jù)并將數(shù)據(jù)轉(zhuǎn)換為可被廣泛的工具分析的格式等等功能的實現(xiàn)。

collectl提供的另一大功能便是像服務(wù)一樣運行,對遠程Linux機器或完整的服務(wù)器集群提供遠程監(jiān)控,其表現(xiàn)堪稱完美。

Collectl同另一批可用于處理分析收集數(shù)據(jù)的名為Collectl實用工具 (colmux, colgui, colplot)的功能相契合。如果有機會,我們在之后的文章中會介紹它們。

為更詳細的了解Collectl工具,請登錄它的主頁來學習更多的功能。筆者建議查看FAQs來快速了解collectl,讀取collectl文檔獲取深層次的例子。等價命令表也可定位至更多的像sar,iostat,netstat,top等和collectl功能部分等價的常用工具。


via: http://www.binarytides.com/collectl-monitor-system-resources-linux/

譯者:icybreaker 校對:wxy

責任編輯:黃丹 來源: linux.cn
相關(guān)推薦

2013-04-10 10:59:45

Linux系統(tǒng)監(jiān)控collectl

2024-10-14 16:53:06

2010-05-26 12:57:59

linux 系統(tǒng)監(jiān)控

2013-08-27 14:40:03

系統(tǒng)監(jiān)控

2011-03-29 11:28:00

Cacti插件

2021-08-17 09:35:26

Linux命令Nginx

2011-03-29 11:28:03

Linux安裝zabbix

2011-03-21 15:42:14

LinuxNagios

2009-10-27 09:26:26

linux系統(tǒng)監(jiān)控命令

2011-01-06 13:45:51

linux流量監(jiān)控iftop

2014-07-30 10:08:26

collectlLinux性能監(jiān)測

2021-12-24 10:15:22

Linux命令lsof

2011-03-29 10:06:40

Cacti

2011-03-29 09:56:35

Cacti界面

2011-03-29 09:39:55

Cacti安裝

2019-12-31 14:00:35

LinuxNginx腳本語言

2009-09-28 10:34:32

LR監(jiān)控Linux系統(tǒng)資源Linux

2022-07-26 10:28:00

Linux監(jiān)控命令

2010-05-19 10:14:41

vmstatLinux系統(tǒng)監(jiān)控工具

2011-08-25 15:23:58

Linux系統(tǒng)監(jiān)控命令
點贊
收藏

51CTO技術(shù)棧公眾號