Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use collectl, an integrated performance monitoring tool for Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Linux integrated performance monitoring tool collectl how to use, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

The most important task for a Linux system administrator is to make sure that the system he or she manages is in a very good condition. Linux system administrators can use many tools to help monitor and display processes in the system, such as top and htop, but none of these tools can match collectl.

Collectl:Linux performance monitoring tool

Collectl is a great, feature-rich command utility that can be used to collect performance data that describes the current state of the system. Unlike most other monitoring tools, collectl does not focus on a limited number of system metrics, but can collect information about many different types of system resources, such as processors, disks, memory, networks, sockets, TCP, Inode, Infiniband, Lustre, NFS, processes, quadric, slab, and partner system information.

A very good aspect of using collectl is that it can also play the role of many other utilities like top, ps, and iotop, which are only designed for a particular purpose. So what features make colleclt a utility?

After a lot of research, I compiled a list of some of the most important features of the collectl command-line utility.

Functional characteristics of collectl

◦ it can run interactively, as a daemon, or both.

◦ it can display output results in a variety of formats.

◦ can monitor almost any subsystem.

◦ can play the role of many other utilities such as ps, top, iotop, or vmstat.

◦ it can record and play back captured data.

◦ it can export data in many file formats. This feature is very useful if you want to use external tools to analyze data.

◦ can be run as a service to monitor remote machines or an entire server cluster.

◦ can display data in the terminal and write the data to a file or socket.

How do I install collectl in Linux?

The collectl utility runs on all Linux distributions, and it only needs perl to run, so make sure you have Perl installed on your machine before you install collectl on your machine.

On Debian/Ubuntu/Linux Mint

The following command can be used to install the collectl utility on Debian-based machines, such as Ubuntu.

$sudo apt-get install collectl

On RHEL/CentOS/Fedora

If you use a Red Hat-based distribution, it's easy to get it from the software library with the yum command.

# yum install collectl

Some practical examples of the collectl utility

Once the collectl tool is installed, you can easily run it from the terminal, even without any options. The following command displays information about processors, disks, network statistics, and so on, in a very short and easy-to-read format.

# collectl waiting for 1 second sample... # # cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut 13 5 790 1322 0 0 92 7 4 13 0 5 10 2 719 1186 0 0 0 3 90 4 12 0 753 1188 0 0 52 32 5 0 6 13 2 733 1063 0 0 0 1 10 1 25 2 834 1375 0 0 0 1 10 1 28 2 870 1424 0 0 36 71 10 1 19 3 949 2271 0 0 44 3 1 1 0 1 17 2 809 1384 0 0 0 16 0 6 16 2 732 1348 0 0 0 1 1 0 1 22 4 993 1615 0 0 56 3 1 2 0 3

As you can see from the above output displayed on the terminal screen, it is very easy to process the system metric value in the command output because it is displayed on a single line.

When the collectl utility executes without any options, it displays information about the following subsystems:

◦ processor

◦ disk

◦ network

Note: in our example, the subsystem refers to each system resource that can be measured.

You can also display statistics for all subsystems except slab, as long as you combine this command with the-all option, as shown below.

# collectl-- all waiting for 1 second sample... # # cpu sys inter ctxsw Cpu0 Cpu1 Free Buff Cach Inac Slab Map Fragments KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut IP Tcp Udp Icmp Tcp Udp Raw Frag Handle Inodes Reads Writes Meta Comm 16 3 817 1542 430 390 1G 175M 1G 683M 193M 1G nsslkjjebbk 0 0 24 3 11 0 1 0 0 0 623 0 0 0 8160 240829 0 0 0 11 1 745 1324 316 426 1G 175M 1G 683M 193M 1G nsslkjjebbk 0 0 0 3 0 2 0 0 0 622 0 0 0 8160 240828 0 0 0 15 2 793 1683 371 424 1G 175M 1G 683M 193M 1G ssslkjjebbk 0 0 0 1 1 0 1 0 0 0 0 622 0 0 0 8160 240829 0 0 0 16 2 872 1875 427 446 1G 175M 1G 683M 193M 1G ssslkjjebbk 0 0 24 3 1 1 0 1 0 0 0 622 0 0 0 8160 240828 0 0 0 24 2 842 1383 473 368 1G 175M 1G 683M 193M 1G ssslkjjebbk 0 0 168 6 1 10 10 0 0 0 622 0 0 0 8160 240828 0 0 0 27 3 844 1099 478 365 1G 175M 1G 683M 193M 1G nsslkjjebbk 0 0 0 16 19 0 0 0 622 0 0 0 8160 240828 0 0 0 0 26 5 823 1238 396 428 1G 175M 1G 683M 193M 1G ssslkjjebbk 0 0 0 2 11 39 0 0 0 622 0 0 0 8160 240828 0 0 0 15 1 753 1276 361 391 1G 175M 1G 683M 193M 1G ssslkjjebbk 0 0 40 3 12 0 3 0 0 0 623 0 0 0 8160 240829 0 0 0

But how do you monitor processor usage with this utility? the "- s" option can be used to control which subsystems data is collected or played back.

For example, the following command can be used to monitor a summary of processor usage.

# collectl-sc waiting for 1 second sample... # # cpu sys inter ctxsw 15 2 749 1155 16 3 772 1445 14 2 793 1247 27 4 887 1292 24 1 796 1258 16 1 743 1113 15 1 743 1179 14 1 706 1078 15 1 764 1268

What happens if you combine commands with "scdn"? The way to learn how to use command-line tools is to use them as practically as possible, so run the following command on your terminal and see what happens.

# collectl-scdn waiting for 1 second sample... # # cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut 25 4 943 3333 0 0 0 1 10 2 27 3 825 2910 0 0 0 1 10 1 27 5 886 2531 0 0 0 1 20 4 872 2406 00 00 1 10 1 26 1 854 2091 00 20 2 1 10 1 39 4 1004 3398 00 00 2 8 3 6 41 6 955 2464 00 40 3 1 2 0 3 25 7 890 1609 0 0 0 11 0 116 2 814 1165 0 0 796 43 2 2 0 2 14 1 779 1383 0 0 48 6 11 0 1 11 2 795 1285 0 0 0 2 14 1 14

It's easy to understand: the default option is "cdn", which represents processor, disk, and network data. The result of the command is the same as the output of "collectl-scn".

If you want to collect data about memory, use the following command.

# collectl-sm waiting for 1 second sample... # # Free Buff Cach Inac Slab Map 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G 1G 177M 1G 684M 193M 1G

The above output is useful if you want to get some detailed information about memory usage, free memory, and other aspects that are important to system performance.

Want to get some data about tcp? This can be done using the following command.

# collectl-st waiting for 1 second sample... # # IP Tcp Udp Icmp 0 0 0

After you have some experience, it is easy to combine many options to get the desired results. For example, you can combine "t" for tcp with "c" for processor. The following command implements this function.

# collectl-stc waiting for 1 second sample... # # cpu sys inter ctxsw IP Tcp Udp Icmp 23 8 961 3136 0 0 0 24 5 916 3662 0 0 0 21 8 848 2408 0 0 0 30 10 916 2674 0 0 0 38 3 826 1752 0 0 0 313 820 1408 0 0 0 15 5 781 1335 0 0 0 17 3 802 1314 0 0 0 17 3 755 1218 0 0 0 14 2 788 1321 0 0 0

It is difficult for us humans to remember all the available options, so I made a summary list of the subsystems supported by the tool.

◦ b-partner system information (memory snippet)

◦ c-processor

◦ d-disk

◦ f-NFS V3 data

◦ I-Inode and file system

◦ j-interrupt

◦ l-Lustre

◦ m-memory

◦ n-network

◦ s-socket

◦ t-TCP

◦ x-Interconnect

◦ y-slabs (system object cache)

A very important piece of data for Linux users' system administrators is the data collected in terms of disk usage. The following command will help you monitor disk usage.

# collectl-sd waiting for 1 second sample... # # KBRead Reads KBWrit Writes 00 00 00 92 7 00 00 00 36 3 00 00 00 100 7 00 00

You can also use the "- sD" option to collect data about individual disks, but you should know that data about all disks will not be reported.

# collectl-sD waiting for 1 second sample... # DISK STATISTICS (/ sec) # Pct # Name KBytes Merged IOs Size Kbytes Merged IOs Size RWSize QLen Wait SvcTim Util sda 0 000 52 11 2 26 26 1 8 8 1 sda 0 000 000 000 sda 0 0 0 24 0 2 12 12 0 0 0 sda 0 0 0 152 0 4 38 38 0 0 0 sda 0 0 0 192 45 3 64 64 1 20 20 5 sda 0 0 0 0 204 02 102 102 0 0 0 sda 0 0 0 sda 0 0 0 116 26 3 39 38 116 16 4 sda 0 0 0 0 0 0 sda 0 0 0 sda 0 0 0 32 5 3 11 10 1 16 16 4 sda 0 0 0 0 0 0

You can also use other specific subsystems to collect detailed data. The specific subsystems are listed below.

◦ C-processor

◦ D-disk

◦ E-Environmental data (fan, power supply, and temperature) via ipmitool

◦ F-NFS data

◦ J-interrupt

Details of ◦ L-Lustre OST, or client file system

◦ N-network

◦ T-65 TCP counters available only in plot format

◦ X-Interconnect

◦ Y-Slabs (system object cache)

◦ Z-process

The collectl utility has many options available, and a single article does not have enough time and space to go through them one by one. However, it is important to understand how to use this utility as top and ps.

It's easy to use collectl as a top utility, just run the following command on your terminal and you'll see similar output from the top tool when executed on a Linux system.

# 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 ^ Couchhammer tecmint 20 1 40 R 1G 626M 0 0.01 0.14 15 28 48.24 00 109 / usr/lib/firefox/firefox 3403 tecmint 20 1 40 R 1G 626M 1 0.00 20 28 PET 48.44 00 0 600 / usr/lib/firefox/firefox 5851 tecmint 20 4666 0 R 17M 13M 0 0.02 0.06 8 00:01.28 00 00 / usr/bin/perl 1682 root 20 1666 2 R 211M 55M 1 0.02 0.01 3 03:10.24 00 0 95 / usr/bin/X 3454 tecmint 20 3403 8 S 216M 45M 1 0.01 0.02 3 01:23.32 00 00 / usr/lib/firefox/plugin-container 4658 tecmint 20 4657 3 S 207M 17M 1 0.00 0.02 2 00:08.23 00 0 142 gnome-terminal 2890 tecmint 20 2571 3 S 340M 68M 0 0.00 0.01 1 01:19.95 00 00 compiz 3521 tecmint 20 1 24 S 710M 148M 1 0.01 0.00 1 01:47.84 00 00 skype 1 root 20 00 S 3M 2M 00.00 0.00 0 00:02.57 00 00 / sbin/init 2 root 20 00 S 00 1 0.00 0.00 0 00:00.00 00 00 kthreadd 3 root 20 20 S 00 00.00 0.00 0 00:00.60 0 00 0 ksoftirqd/0 5 root 0 2 0 S 00 00.00 0.00 0 00:00.00 00 00 kworker/0:0H 7 root 0 2 0 S 00 00.00 0.00 0 00:00.00 00 00 kworker/u:0H 8 root RT 2 0 S 0 00 0.00 0.00 0 00:04.42 00 00 migration/0 9 root 20 20 S 00 00.00 0.00 0 00:00.00 00 00 rcu_bh 10 root 20 20 R 00 00.00 0.00 0 00:02.22 00 00 rcu_sched 11 Root RT 20 S 00 0 0.00 0.00 0 00:00.05 00 00 watchdog/0 12 root RT 20 S 00 1 0.00 0.00 0 00:00.07 00 00 watchdog/1 13 root 20 20 S 00 1 0.00 0.00 0 00:00.73 0 00 0 ksoftirqd/1 14 root RT 2 0 S 00 1 0.00 0.00 0 00:01.96 00 00 migration/1 16 root 0 2 0 S 00 1 0.00 0.00 0 00:00.00 00 00 kworker/1:0H 17 root 0 2 0 S 00 1 0 . 00 0.00 0 00:00.00 00 00 cpuset

Now, but not least, to use the collectl utility as a ps tool, run the following command on your terminal. You will get information about the processes in the system, just like the output you get when you run the "ps" command on the terminal.

# collectl-C1-sZ-iRu 1 waiting for 1 second sample... # RECORD 1 > > tecmint-vgn-z13gn

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report