In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to install and use the system monitoring tool Collectl in Linux. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
System resource monitoring
As a lightweight monitoring tool, Collectl is the most functional tool of its kind. Users can monitor different complex system matrix values and retain data for later analysis. Unlike other tools that only monitor specific system parameters, Collectl can monitor different variables at the same time and record them in an appropriate manner.
Unlike or focusing on a small group of statistics, using a unique output mode, or using iteration as most of the monitoring tools that the daemon runs, collectl can all be implemented at the same time. Users can select any of various subsystems to monitor information including memory, CPU, disk, Inode, wireless bandwidth, lustre, memory, network, network file system, process, quadratic, slabs, socket and TCP.
Let's take a look at the following commands before we go any further.
$collectl
Waiting for1 second sample. . .
# "- CPU-"- Disks-"- Network-"
# cpu sys inter ctxsw KBRead Reads KBWrit Writes KBIn PktIn KBOut PktOut
00864177200000100
521338273400820001
1012222647009230201
107631722008030102
CPU usage, disk input and output, and network activity are loaded per second. The information is easy for people who can understand the data. This list continues to grow over a given interval and can directly form a file tracking log. The collectl tool provides a variety of commands to record, find, and do other processing of this data.
Install collectl tools
Collectl is the default resource for Ubuntu/Debian users, so you can get it using the apt command.
$sudo apt-get install collectl
Fedora/CentOS users can get it by using the yum command.
$yum install collectl
Use
Necessary understanding-Collectl subsystem
Subsystems are different types of system resources that can be detected. Such as CPU, memory, bandwidth and so on can form a subsystem. Running only the collectl command will output CPU, disk, and network subsystem information in batch mode, as we saw above.
As you can see from the instructions, Collectl can identify the following subsystems.
Total subsystem
B-buddy info (memory fragment)
C-CPU
D-Disk
F-NFS V3 Data
I-InodeandFileSystem
J-Interrupts
L-Lustre
M-Memory
N-Networks
S-Sockets
T-TCP
X-Interconnect
Y-Slabs (system object caches)
Detail subsystem
This is a series of details, which in most cases are derived from the corresponding total data. At present, there is no corresponding total data for the two categories "environment variables" and "processes". If you have three disks, select-sd, and you will only see a single message from a combination of three disks. If you select-sD, each disk information will be displayed separately.
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
Use "- s" to monitor a specific subsystem and add subsystem identifiers to it. Now let's give a few examples.
1. Monitor cpu utilization
Using "- sc" to monitor the total utilization rate of CPU
$collectl-sc
Waiting for1 second sample. . .
# "- CPU-"
# cpu sys inter ctxsw
3018003729
3017673599
Use "- C" to observe individual CPU usage. The result will be multiple lines, each corresponding to a CPU.
$collectl-sC
Waiting for1 second sample. . .
# SINGLE CPU STATISTICS
# Cpu User Nice Sys Wait IRQ Soft Steal Idle
0300000096
1300000096
2200000097
3100000098
0200000097
1202000095
2100000098
3401000095
If necessary, you can use both C and c to obtain individual CPU monitoring data and summary data.
two。 Memory monitoring
Use the m subsystem to view memory.
$collectl-sm
Waiting for1 second sample. . .
# "- Memory-"
# Free Buff Cach Inac Slab Map
2G220M1G1G210M3G
2G220M1G1G210M3G
2G220M1G1G210M3G
It's not hard to explain. M is used to view more memory details.
$collectl-sM
Waiting for1 second sample. . .
# MEMORY STATISTICS
# Node Total Used Free Slab Mapped Anon Locked Inact Hit%
07975M5939M2036M215720K372184K06652K1434M0
07975M5939M2036M215720K372072K06652K1433M0
3. View disk usage
D and D can view an overview and details of disk usage.
$collectl-sd
Waiting for1 second sample. . .
# "- Disks-"
# KBRead Reads KBWrit Writes
4113624
008013
$collectl-sD
Waiting for1 second sample. . .
# DISK STATISTICS (/ sec)
# "- reads-"- writes-"- averages-" Pct
# Name KBytes Merged IOs Size KBytes Merged IOs Size RWSize QLen Wait SvcTim Util
Sda 0000000000000
Sda 0000000000000
Sda 10211715322621
Sda 0000921151818112125
The "--verbose" command can be used to view additional information. Unlike the D command, it extends the profile to include more information.
$collectl-sd-verbose
4. Report on multiple systems at the same time
If you want to get CPU, memory and disk reports at the same time, use a combination of subcommands at the same time.
$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. Show statistical time
To display the monitoring information for each line with the time, use the T option. It is specified by the "- o" parameter.
$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
Use "- oTm" to change the time to millisecond display.
6. Change the sample count
Each line of the collectl report is a snapshot or sample, and it usually sets periodic intervals such as 1 second to sample. I can be used to set the time interval and c to set the sample count.
$collectl-C1-sm
Waiting for1 second sample. . .
# "- Memory-"
# Free Buff Cach Inac Slab Map
1G261M1G1G228M3G
Use the I command to change the update interval.
$collectl-sm-i2
Waiting for2 second sample. . .
# "- Memory-"
# Free Buff Cach Inac Slab Map
1G261M1G1G229M3G
The above command sets memory information to be collected every 2 seconds.
7. Use collectl like iotop
The top command makes collectl do intelligent statistics like an iostat/top tool. The list is constantly updated and can be sorted using different fields.
$collectl-top iokb
The output is as follows
# 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
The above output is very similar to the top command, and it sorts processes in descending order of the number of disks.
If you want to show only the above five processes, you can use the following command
$collectl-top iokb,5
To learn which fields in the list above can be sorted, use the following command
$collectl-showtopopts
The following is a list of the highest sort types applied to processes or data. In some cases you may use a field to sort, but it is not part of the display.
TOP PROCESS SORT FIELDS
Process sort field
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 take 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. Use collectl like top
To make collectl look like top, we just need to sort the output processes by CPU usage.
$collectl-top
The output is as follows
# 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:
The above command can also be used to display subsystem information.
$collectl-top-scm
9. List processes like ps
To list all processes like the ps command with no subsequent updates, use the "c" command to count them to 1. $collectl-C1-sZ-iV1
The above command will list all processes similar to the "ps-e" command. "procfilt" is used to filter out specific process information from all processes. "procopts" is used to specify another set of commands to fine-tune the list of processes.
10. Use collectl like vmstat
Collectl has built-in commands to perform functions like 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. Details of the subsystem
The following command counts CPU information five times at one-second intervals and displays detailed information along with the time (verbose).
$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
Change the "- s" variable to see the different subsystems.
The above is how to install and use the system monitoring tool Collectl for Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.