您好,登錄后才能下訂單哦!
這篇文章跟大家分析一下“Linux系統(tǒng)監(jiān)控工具Collectl怎么用”。內(nèi)容詳細(xì)易懂,對(duì)“Linux系統(tǒng)監(jiān)控工具Collectl怎么用”感興趣的朋友可以跟著小編的思路慢慢深入來閱讀一下,希望閱讀后能夠?qū)Υ蠹矣兴鶐椭?。下面跟著小編一起深入學(xué)習(xí)“Linux系統(tǒng)監(jiān)控工具Collectl怎么用”的知識(shí)吧。
Linux系統(tǒng)管理員為了使系統(tǒng)良好的運(yùn)轉(zhuǎn)通常會(huì)使用otop,top,free,htop,sar等豐富的常規(guī)工具來監(jiān)測(cè)cpu,內(nèi)存,磁盤,網(wǎng)絡(luò)等系統(tǒng)信息,下面和大家一款集測(cè)試/監(jiān)控/分析系統(tǒng)性能為一體的Linux工具-collectl。
安裝collectl工具
對(duì)Ubuntu/Debian用戶來說Collectl是默認(rèn)資源,所以使用apt命令便可獲取。
$ sudo apt-get install collectl
Fedora/CentOS用戶使用yum命令便可獲取。
$ yum install collectl
子系統(tǒng)是可檢測(cè)到的不同系統(tǒng)資源類型。像CPU,內(nèi)存,帶寬等等都可構(gòu)成一個(gè)子系統(tǒng)。只運(yùn)行collectl命令將以批處理模式輸出CPU,磁盤和網(wǎng)絡(luò)子系統(tǒng)信息,我們?cè)谏衔囊芽吹较嚓P(guān)內(nèi)容。
從操作說明可以看到,Collectl可以識(shí)別以下子系統(tǒng)。
總計(jì)子系統(tǒng)
b – buddy info (內(nèi)存片段)
c – CPU
d – Disk
f – NFS V3 Data
i – Inode and File System
j – Interrupts
l – Lustre
m – Memory
n – Networks
s – Sockets
t – TCP
x – Interconnect
y – Slabs (system object caches)
細(xì)節(jié)子系統(tǒng)
這是一系列的詳細(xì)信息,大部分情況下都會(huì)由相應(yīng)的總計(jì)數(shù)據(jù)衍生出來。目前“環(huán)境變量”和“進(jìn)程”2類沒有相應(yīng)的總計(jì)數(shù)據(jù)。如果有3個(gè)磁盤,選擇-sd,將只會(huì)看到3個(gè)磁盤組合出的單一信息。如果選擇-sD,將會(huì)分別顯示各磁盤信息。
C – CPU
D – Disk
E – Environmental data (fan, power, temp), via ipmitool
F – NFS Data
J – Interrupts
L – Lustre OST detail OR client Filesystem detail
M – Memory node data, which is also known as numa data
N – Networks
T – 65 TCP counters only available in plot format
X – Interconnect
Y – Slabs (system object caches)
Z – Processes
使用“-s”來監(jiān)測(cè)特定的子系統(tǒng)并向其添加子系統(tǒng)的識(shí)別項(xiàng)?,F(xiàn)在讓我們舉幾個(gè)例子。
用“-sc”實(shí)現(xiàn)CPU總使用率的監(jiān)測(cè)
$ collectl –sc
waiting for 1 second sample…
#CPU——–>
#cpu sys inter ctxsw
3 0 1800 3729
3 0 1767 3599
使用“-C”觀察各個(gè)單獨(dú)的CPU使用情況。結(jié)果將會(huì)輸出多行,分別對(duì)應(yīng)一個(gè)CPU。
$ collectl –sC
waiting for 1 second sample…
# SINGLE CPU STATISTICS
# Cpu User Nice Sys Wait IRQ Soft Steal Idle
0 3 0 0 0 0 0 0 96
1 3 0 0 0 0 0 0 96
2 2 0 0 0 0 0 0 97
3 1 0 0 0 0 0 0 98
0 2 0 0 0 0 0 0 97
1 2 0 2 0 0 0 0 95
2 1 0 0 0 0 0 0 98
3 4 0 1 0 0 0 0 95
如果需要,可以同時(shí)使用C和c來獲取單項(xiàng)CPU監(jiān)測(cè)數(shù)據(jù)和匯總數(shù)據(jù)。
使用m子系統(tǒng)查看內(nèi)存。
$ collectl –sm
waiting for 1 second sample…
#Memory———–>
#Free Buff Cach Inac Slab Map
2G 220M 1G 1G 210M 3G
2G 220M 1G 1G 210M 3G
2G 220M 1G 1G 210M 3G
不難解釋。 M用來查看更多內(nèi)存的詳細(xì)信息。
$ collectl –sM
waiting for 1 second sample…
# MEMORY STATISTICS
# Node Total Used Free Slab Mapped Anon Locked Inact Hit%
0 7975M 5939M 2036M 215720K 372184K 0 6652K 1434M 0
0 7975M 5939M 2036M 215720K 372072K 0 6652K 1433M 0
這類似于免費(fèi)報(bào)告嗎?
d和D可以查看磁盤使用的概況和詳細(xì)情況。
$ collectl –sd
waiting for 1 second sample…
#Disks———–>
#KBRead Reads KBWrit Writes
4 1 136 24
0 0 80 13
$ collectl –sD
waiting for 1 second sample…
# DISK STATISTICS (/sec)
# reads———>writes———>averages——–> Pct
#Name KBytes Merged IOs Size KBytes Merged IOs Size RWSize QLen Wait SvcTim Util
sda 0 0 0 0 0 0 0 0 0 0 0 0 0
sda 0 0 0 0 0 0 0 0 0 0 0 0 0
sda 1 0 2 1 17 1 5 3 2 2 6 2 1
sda 0 0 0 0 92 11 5 18 18 1 12 12 5
“–verbose”命令可以用來查看附加信息。和D命令不同,它將概況擴(kuò)展,包含了更多信息。
$ collectl –sd —verbose
如果想要同時(shí)得到CPU,內(nèi)存和磁盤報(bào)告,那么同時(shí)使用子命令組合來實(shí)現(xiàn)。
$ collectl –scmd
waiting for 1 second sample…
#CPU——–>Memory———–>Disks———–>
#cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes
4 0 2187 4334 1G 221M 1G 1G 210M 3G 0 0 0 0
3 0 1896 4065 1G 221M 1G 1G 210M 3G 0 0 20 5
若要將每行的監(jiān)測(cè)信息和時(shí)間一同顯示,使用T選項(xiàng)。通過在“-o”參數(shù)來指定。
$ collectl –scmd –oT
waiting for 1 second sample…
# CPU——–>Memory———–>Disks———–>
#Time cpu sys inter ctxsw Free Buff Cach Inac Slab Map KBRead Reads KBWrit Writes
12:03:05 3 0 1961 4013 1G 225M 1G 1G 212M 3G 0 0 0 0
12:03:06 3 0 1884 3810 1G 225M 1G 1G 212M 3G 0 0 0 0
12:03:07 3 0 2011 4060 1G 225M 1G 1G 212M 3G 0 0 0 0
使用“-oTm”可將時(shí)間換成毫秒顯示。
collectl報(bào)告的每行都是一份快照或樣本,它通常設(shè)定定期間隔如1秒來取樣。i可用來設(shè)置時(shí)間間隔,c用來設(shè)置樣本計(jì)數(shù)。
$ collectl –c1 –sm
waiting for 1 second sample…
#Memory———–>
#Free Buff Cach Inac Slab Map
1G 261M 1G 1G 228M 3G
使用i命令可改變更新時(shí)間間隔。
$ collectl –sm –i2
waiting for 2 second sample…
#Memory———–>
#Free Buff Cach Inac Slab Map
1G 261M 1G 1G 229M 3G
上面的命令設(shè)定每2秒收集一次內(nèi)存信息。
top命令將collectl像iostat/top工具一樣進(jìn)行智能統(tǒng)計(jì)。列表會(huì)持續(xù)更新,且可以使用不同字段實(shí)現(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 20 2683 3 S 938M 33M 0 0.00 0.00 0 00:09.16 0 4 0 0 /usr/bin/ktorrent
1 root 20 0 0 S 26M 3M 2 0.00 0.00 0 00:01.30 0 0 0 0 /sbin/init
2 root 20 0 0 S 0 0 3 0.00 0.00 0 00:00.00 0 0 0 0 kthreadd
3 root 20 2 0 S 0 0 0 0.00 0.00 0 00:00.02 0 0 0 0 ksoftirqd/0
4 root 20 2 0 S 0 0 0 0.00 0.00 0 00:00.00 0 0 0 0 kworker/0:0
5 root 0 2 0 S 0 0 0 0.00 0.00 0 00:00.00 0 0 0 0 kworker/0:0H
7 root RT 2 0 S 0 0 0 0.00 0.00 0 00:00.08 0 0 0 0 migration/0
8 root 20 2 0 S 0 0 2 0.00 0.00 0 00:00.00 0 0 0 0 rcu_bh
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ù)量降序排列進(jìn)程。
若只想顯示上面的5項(xiàng)進(jìn)程,可用以下命令實(shí)現(xiàn)
$ collectl —top iokb,5
若想學(xué)習(xí)上面的列表里哪些字段可以排序,使用如下命令
$ collectl —showtopopts
下面是應(yīng)用于進(jìn)程或數(shù)據(jù)的最高排序類型列表。某些情況下你可能會(huì)使用某一字段進(jìn)行排序,但它并非顯示的一部分。
TOP PROCESS SORT FIELDS
進(jìn)程排序字段
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
Page Faults
majf major page faults
minf minor page faults
flt total page faults
Context Switches
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
為使collectl像top,我們只需以CPU使用率排序輸出進(jìn)程。
$ 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 20 9102 0 R 63M 22M 3 0.03 0.10 13 00:00.81 0 0 0 3 /usr/bin/perl
3076 enlighte 20 2683 2 S 521M 40M 2 0.00 0.03 3 00:55.14 0 0 0 2 /usr/bin/yakuake
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
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
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
1186 root 20 1152 4 S 502M 76M 0 0.00 0.01 1 03:02.96 0 0 0 0 /usr/bin/X
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)信息。
$ collectl —top –scm
為像ps命令一樣列出所有進(jìn)程且沒有后續(xù)更新,用“c”命令讓其計(jì)數(shù)至1. $ collectl -c1 -sZ -i:1
上面的命令將會(huì)列出類似“ps -e”命令的所有進(jìn)程?!皃rocfilt”用于從所有進(jìn)程中過濾出特定的進(jìn)程信息。“procopts”用于指定另一組微調(diào)進(jìn)程列表顯示的命令。
Collectl有內(nèi)置命令來完成像vmstat一樣的功能。
$ collectl —vmstat
waiting for 1 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
1 0 0 1733M 242M 1922M 1137M 710M 0 0 0 108 1982 3918 2 0 95 1
1 0 0 1733M 242M 1922M 1137M 710M 0 0 0 0 1906 3886 1 0 98 0
1 0 0 1733M 242M 1922M 1137M 710M 0 0 0 0 1739 3480 3 0 96 0
下面的命令以一秒為間隔,統(tǒng)計(jì)5次CPU信息并和時(shí)間一起顯示出詳細(xì)信息(冗長(zhǎng))。
$ collectl –sc –c5 –i1 —verbose –oT
waiting for 1 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:10 11 0 0 0 0 0 0 87 4 1312 2691 0 866 1 0.78 0.86 0.78 1 0
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
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
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
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)。
關(guān)于Linux系統(tǒng)監(jiān)控工具Collectl怎么用就分享到這里啦,希望上述內(nèi)容能夠讓大家有所提升。如果想要學(xué)習(xí)更多知識(shí),請(qǐng)大家多多留意小編的更新。謝謝大家關(guān)注一下億速云網(wǎng)站!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。