你可以很容易就明白默认选项是“cdn”,它代表cpu、硬盘和网络数据。运行带这个选项的 collectl 命令的输出和“collectl -scn”的输出一样。
如果你想采集内存的数据,用下面的命令。
- # collectl -sm
- waiting for1 second sample...
- #
- #Free Buff Cach Inac Slab Map
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
- 1G177M1G684M193M1G
当你想要进一步了解内存使用信息、空闲的内存或者与你系统性能有关的重要资料时,上面的输出将是非常有用的。
如果想搜集一点儿 tcp 的数据呢?使用下面的命令来实现吧。
- # collectl -st
- waiting for1 second sample...
- #
- # IP Tcp Udp Icmp
- 0000
- 0000
- 0000
- 0000
- 0000
- 0000
- 0000
- 0000
- 0000
- 0000
- 0000
当你熟练到一定程度时,你就可以很轻松地得到你想要的结果了。例如你可以将关于 tcp 的“t”选项和关于 cpu 的“c”选项组合到一起。下面的命令就是如此。
- # collectl -stc
- waiting for1 second sample...
- #
- #cpu sys inter ctxsw IP Tcp Udp Icmp
- 23896131360000
- 24591636620000
- 21884824080000
- 301091626740000
- 38382617520000
- 31382014080000
- 15578113350000
- 17380213140000
- 17375512180000
- 14278813210000
对于我们普通大众来说记住这些选项很困难,所以在这里,我整理出了一个列表来总结这个工具支持的选项。
- b – buddy info (内存碎片)
- 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 (系统对象缓存)
对于一个系统管理员或者一个 Linux 用户来说很重要的一种数据就是硬盘的使用情况。下面的命令可以帮你监控硬盘使用情况。
- # collectl -sd
- waiting for1 second sample...
- #
- #KBRead Reads KBWrit Writes
- 0000
- 0000
- 00927
- 0000
- 00363
- 0000
- 0000
- 001007
- 0000
你也可以使用“-sD”选项来采集单个硬盘的数据,不过你必须知道这就不会显示全部硬盘的信息。
- # collectl -sD
- waiting for1 second sample...
- # DISK STATISTICS (/sec)
- # Pct
- #Name KBytes Merged IOs Size KBytes Merged IOs Size RWSize QLen Wait SvcTim Util
- sda 00005211226261881
- sda 0000000000000
- sda 0000240212120000
- sda 00001520438380000
- sda 00001924536464120205
- sda 0000204021021020000
- sda 0000000000000
- sda 00001162633938116164
- sda 0000000000000
- sda 0000000000000
- sda 000032531110116164
- sda 0000000000000
你也可以使用其它详细的子系统来采集详细的数据。下面是详细子系统的一个列表。
- 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
- N – Networks
- T – 65 TCP counters only available in plot format
- X – Interconnect
- Y – Slabs (system object caches)
- Z – Processes
collectl 工具中有许多选项,但是仅用一篇文章来介绍肯定是介绍不过来的。然而如果将它当作 top 和 ps 工具来使用还是值得一提的。
很容易将 collectl 当作 top 来使用,只要在 Linux 系统的终端运行下面的命令你就会看到和 top 工具类似的输出。
- # collectl --top
- # TOP PROCESSES sorted by time (counters are /sec) 13:11:02
- # PID User PR PPID THRD S VSZ RSS CP SysT UsrT Pct AccuTime RKB WKB MajF MinF Command
- ^COuch!tecmint 20140 R 1G626M00.010.141528:48.24000109/usr/lib/firefox/firefox
- 3403 tecmint 20140 R 1G626M10.000.202028:48.44000600/usr/lib/firefox/firefox
- 5851 tecmint 2046660 R 17M13M00.020.06800:01.280000/usr/bin/perl
- 1682 root 2016662 R 211M55M10.020.01303:10.2400095/usr/bin/X
- 3454 tecmint 2034038 S 216M45M10.010.02301:23.320000/usr/lib/firefox/plugin-container
- 4658 tecmint 2046573 S 207M17M10.000.02200:08.23000142 gnome-terminal
- 2890 tecmint 2025713 S 340M68M00.000.01101:19.950000 compiz
- 3521 tecmint 20124 S 710M148M10.010.00101:47.840000 skype
- 1 root 2000 S 3M2M00.000.00000:02.570000/sbin/init
- 2 root 2000 S 0010.000.00000:00.000000 kthreadd
- 3 root 2020 S 0000.000.00000:00.600000 ksoftirqd/0
- 5 root 020 S 0000.000.00000:00.000000 kworker/0:0H
- 7 root 020 S 0000.000.00000:00.000000 kworker/u:0H
- 8 root RT 20 S 0000.000.00000:04.420000 migration/0
- 9 root 2020 S 0000.000.00000:00.000000 rcu_bh
- 10 root 2020 R 0000.000.00000:02.220000 rcu_sched
- 11 root RT 20 S 0000.000.00000:00.050000 watchdog/0
- 12 root RT 20 S 0010.000.00000:00.070000 watchdog/1
- 13 root 2020 S 0010.000.00000:00.730000 ksoftirqd/1
- 14 root RT 20 S 0010.000.00000:01.960000 migration/1
- 16 root 020 S 0010.000.00000:00.000000 kworker/1:0H
- 17 root 020 S 0010.000.00000:00.000000 cpuset
最后,当然不是说这不重要,我们在终端运行下面的命令就可以将 collectl 用作 ps 工具了。 你可以得到关于你系统进程的信息,这和在终端运行“ps”命令是一样的。
- # collectl -c1 -sZ -i:1
- waiting for1 second sample...
- ### RECORD 1 >>> tecmint-vgn-z13gn <<< (1397979716.001) (Sun Apr 20 13:11:56 2014) ###
- # PROCESS SUMMARY (counters are /sec)
- # PID User PR PPID THRD S VSZ RSS CP SysT UsrT Pct AccuTime RKB WKB MajF MinF Command
- 1 root 2000 S 3M2M00.000.00000:02.570000/sbin/init
- 2 root 2000 S 0010.000.00000:00.000000 kthreadd
- 3 root 2020 S 0000.000.00000:00.600000 ksoftirqd/0
- 5 root 020 S 0000.000.00000:00.000000 kworker/0:0H
- 7 root 020 S 0000.000.00000:00.000000 kworker/u:0H
- 8 root RT 20 S 0000.000.00000:04.420000 migration/0
- 9 root 2020 S 0000.000.00000:00.000000 rcu_bh
- 10 root 2020 S 0000.000.00000:02.240000 rcu_sched
- 11 root RT 20 S 0000.000.00000:00.050000 watchdog/0
- 12 root RT 20 S 0010.000.00000:00.070000 watchdog/1
- 13 root 2020 S 0010.000.00000:00.730000 ksoftirqd/1
- 14 root RT 20 S 0010.000.00000:01.960000 migration/1
- 16 root 020 S 0010.000.00000:00.000000 kworker/1:0H
- 17 root 020 S 0010.000.00000:00.000000 cpuset
- 18 root 020 S 0010.000.00000:00.000000 khelper
- 19 root 2020 S 0000.000.00000:00.000000 kdevtmpfs
- 20 root 020 S 0000.000.00000:00.000000 netns
- 21 root 2020 S 0000.000.00000:00.000000 bdi-default
- 22 root 020 S 0000.000.00000:00.000000 kintegrityd
我确信许多系统管理员将会喜欢这个工具并且在充分使用它后会感受到它的强大。如果你想增进你对 collectl 的了解,从而达到新的层面,你可以去参阅 collectl 的 man 手册并勤加练习。
在你的终端键入下面的命令开始阅读吧。
- # man collectl
参考链接
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/102805.htm
