系統(tǒng)之家 - 系統(tǒng)光盤下載網(wǎng)站!

當前位置:系統(tǒng)之家 > 系統(tǒng)教程 > Linux安裝使用Collectl

Linux安裝使用監(jiān)控軟件Collectl的方法(2)

時間:2015-02-04 17:12:39 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時看資訊 2. 請使用手機瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150204/37030.html 手機查看 評論

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

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

  $ collectl -scmd

  waiting for1 second sample.。。

  #《--------CPU--------》《-----------Memory-----------》《----------Disks-----------》

  #cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes

  40218743341G221M1G1G210M3G0000

  30189640651G221M1G1G210M3G00205

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

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

  $ collectl -scmd -oT

  waiting for1 second sample.。。

  # 《--------CPU--------》《-----------Memory-----------》《----------Disks-----------》

  #Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes

  12:03:0530196140131G225M1G1G212M3G0000

  12:03:0630188438101G225M1G1G212M3G0000

  12:03:0730201140601G225M1G1G212M3G0000

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

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

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

  $ collectl -c1 -sm

  waiting for1 second sample.。。

  #《-----------Memory-----------》

  #Free Buff Cach Inac Slab Map

  1G261M1G1G228M3G

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

  $ collectl -sm -i2

  waiting for2 second sample.。。

  #《-----------Memory-----------》

  #Free Buff Cach Inac Slab Map

  1G261M1G1G229M3G

  上面的命令設定每2秒收集一次內存信息。

  7. 像iotop一樣使用collectl

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

  $ collectl --top iokb

  輸出如下

  # TOP PROCESSES sorted by iokb (counters are /sec) 09:44:57

  # PID User PR PPID THRD S VSZ RSS CP SysT UsrT Pct AccuTime RKB WKB MajF MinF Command

  3104 enlighte 2026833 S 938M33M00.000.00000:09.160400/usr/bin/ktorrent

  1 root 2000 S 26M3M20.000.00000:01.300000/sbin/init

  2 root 2000 S 0030.000.00000:00.000000 kthreadd

  3 root 2020 S 0000.000.00000:00.020000 ksoftirqd/0

  4 root 2020 S 0000.000.00000:00.000000 kworker/0:0

  5 root 020 S 0000.000.00000:00.000000 kworker/0:0H

  7 root RT 20 S 0000.000.00000:00.080000 migration/0

  8 root 2020 S 0020.000.00000:00.000000 rcu_bh

  9 root 2020 S 0000.000.00000:00.000000 rcuob/0

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

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

  $ collectl --top iokb,5

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

  $ collectl --showtopopts

  下面是應用于進程或數(shù)據(jù)的最高排序類型列表。某些情況下你可能會使用某一字段進行排序,但它并非顯示的一部分。

  TOP PROCESS SORT FIELDS

  進程排序字段

  Memory

  vsz virtual memory

  rss resident (physical) memory

  Time

  syst system time

  usrt user time

  time total time

  accum accumulated time

  I/O

  rkb KB read

  wkb KB written

  iokb total I/O KB

  rkbc KB read from pagecache

  wkbc KB written to pagecache

  iokbc total pagecacge I/O

  ioall total I/O KB (iokb+iokbc)

  rsys read system calls

  wsys write system calls

  iosys total system calls

  iocncl Cancelled write bytes

  PageFaults

  majf major page faults

  minf minor page faults

  flt total page faults

  ContextSwitches

  vctx volunary context switches

  nctx non-voluntary context switches

  Miscellaneous(best when used with--procfilt)

  cpu cpu number

  pid process pid

  thread total process threads (not counting main)

  TOP SLAB SORT FIELDS

  numobj total number of slab objects

  actobj active slab objects

  objsize sizes of slab objects

  numslab number of slabs

  objslab number of objects in a slab

  totsize total memory sizes taken by slabs

  totchg change in memory sizes

  totpct percent change in memory sizes

  name slab names

  8. 像top一樣使用collectl

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

  $ collectl --top

  輸出如下

  # TOP PROCESSES sorted by time (counters are /sec) 14:08:46

  # PID User PR PPID THRD S VSZ RSS CP SysT UsrT Pct AccuTime RKB WKB MajF MinF Command

  9471 enlighte 2091020 R 63M22M30.030.101300:00.810003/usr/bin/perl

  3076 enlighte 2026832 S 521M40M20.000.03300:55.140002/usr/bin/yakuake

  3877 enlighte 20335641 S 1G218M10.000.03310:10.500000/opt/google/chrome/chrome

  4625 enlighte 20289536 S 1G241M20.000.02208:24.3900012/usr/lib/firefox/firefox

  5638 enlighte 2033563 S 1G265M10.000.02209:55.040002/opt/google/chrome/chrome

  1186 root 2011524 S 502M76M00.000.01103:02.960000/usr/bin/X

  1334 www-data 2013290 S 87M1M20.000.01100:00.850000 nginx:

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

  $ collectl --top -scm

  9. 像ps一樣列出進程

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

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

  10. 像vmstat一樣使用collectl

  Collectl有內置命令來完成像vmstat一樣的功能。

  $ collectl --vmstat

  waiting for1 second sample.。。

  #procs ---------------memory (KB)--------------- --swaps-- -----io---- --system-- ----cpu-----

  # r b swpd free buff cache inact active si so bi bo in cs us sy id wa

  1001733M242M1922M1137M710M0001081982391820951

  1001733M242M1922M1137M710M00001906388610980

  1001733M242M1922M1137M710M00001739348030960

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

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

  $ collectl -sc -c5 -i1 --verbose -oT

  waiting for1 second sample.。。

  # CPU SUMMARY (INTR, CTXSW & PROC /sec)

  #Time User Nice Sys Wait IRQ Soft Steal Idle CPUs Intr Ctxsw Proc RunQ Run Avg1 Avg5 Avg15 RunT BlkT

  14:22:101100000087413122691086610.780.860.7810

  14:22:111500000084412832496086610.780.860.7810

  14:22:121700000082413422658086600.780.860.7800

  14:22:131500000084412412429086610.780.860.7810

  14:22:141100000088412702488086600.800.870.7800

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

  總結

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

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

  Collectl同另一批可用于處理分析收集數(shù)據(jù)的名為Collectl實用工具 (colmux, colgui, colplot)的功能相契合。

  上面就是Linux安裝和使用Collectl的方法介紹了,Collectl能夠完成像ps、top、vmstat這些監(jiān)控命令一樣的功能,且還有其他的功能,比單純的使用命令簡單。

發(fā)表評論

0

沒有更多評論了

評論就這些咯,讓大家也知道你的獨特見解

立即評論

以上留言僅代表用戶個人觀點,不代表系統(tǒng)之家立場

其他版本軟件

熱門教程

人氣教程排行

Linux系統(tǒng)推薦

官方交流群 軟件收錄