How to use the command 'atop' (with examples)
- Linux
- December 25, 2023
The ‘atop’ command is a Linux system and process monitor. It provides detailed information about system resources, individual processes, disk usage, and more. This command is useful for monitoring system performance, analyzing resource utilization, and troubleshooting performance issues.
Use case 1: Start
Code:
atop
Motivation: Starting ‘atop’ without any arguments allows you to view a real-time summary of system resource utilization, including CPU usage, memory consumption, disk I/O, and network activity. This can be helpful in monitoring the overall health of the system and identifying any abnormalities or resource bottlenecks.
Example output:
ATOP - pre 11:57:13 interval: 10 seconds
PRC | sys 0.05s | user 0.70s | #proc 11 | #trun 2 | #tslpi 51 #tslpu 0
CPU | sys 9% | usr 90% | irq 0% | idle 1% | wait 0% | steal 0%
CPL | avg1 0.97 | avg5 0.98 | avg15 0.87 | csw 307687 | intr 79235
MEM | tot 7.6G | free 6.0G | cache 249.0M | buff 13.0M
SWP | tot 4.0G | free 4.0G
Use case 2: Start and display memory consumption for each process
Code:
atop -m
Motivation: This command provides detailed information about memory consumption for each individual process running on the system. By monitoring memory usage, you can identify memory-intensive processes and analyze memory utilization patterns.
Example output:
PRC | sys 0.00s | user 0.07s | #proc 11 | #trun 1 | #tslpi 56 #tslpu 0
MEM | tot 7.6G | free 6.0G | cache 248.4M | buff 13.0M
SWP | tot 4.0G | free 4.0G
PID MINFLT MAJFLT VSTEXT VSIZE RSIZE VGROW RGROW MEM Command
327 0.00 0.00 1736 824K 180K +0.0K +0.0K 0.2% atd
349 0.00 0.00 2550 1120K 288K +0.0K +0.0K 0.3% rsyslogd
...
Use case 3: Start and display disk information
Code:
atop -d
Motivation: Monitoring disk activity can help identify performance and utilization issues related to storage. This command provides detailed information about disk I/O, including read and write rates, average queue length, and more. It can be useful in troubleshooting slow disk performance or identifying processes causing high disk activity.
Example output:
DSK | sda | busy 9% | read 3 | write 112 | avio 1 ms |
DSK | sdb | busy 0% | read 0 | write 0 | avio 0 ms |
DSK | sdc | busy 3% | read 2 | write 43 | avio 0 ms |
DSK | sdd | busy 0% | read 0 | write 0 | avio 0 ms |
DSK | sde | busy 0% | read 0 | write 0 | avio 0 ms |
...
Use case 4: Start and display background process information
Code:
atop -c
Motivation: Background processes can have a significant impact on system performance and resource utilization. This command allows you to view detailed information about background processes, including their resource consumption, CPU usage, memory usage, and more. It can be helpful in identifying resource-intensive background processes and troubleshooting performance issues.
Example output:
PRC | sys 0.08s | user 3.28s | #proc 123 | #trun 1 | #tslpi 310 #tslpu 0
CPU | sys 7% | usr 93% | irq 0% | idle 2% | wait 0% | steal 0%
CPL | avg1 0.99 | avg5 0.98 | avg15 0.98 | csw 364643 | intr 82224
...
Use case 5: Start and display thread-specific resource utilization information
Code:
atop -y
Motivation: Thread-specific resource utilization information can provide insights into the performance of multi-threaded applications and identify potential bottlenecks or resource contention issues. This command shows CPU usage, memory usage, and other resource metrics for each thread running on the system.
Example output:
CPU | sys 0.00s | user 0.36s | #proc 15 | #trun 1 | #tslpi 54 #tslpu 0
CPL | avg1 0.94 | avg5 0.95 | avg15 0.89 | csw 232771 | intr 57240
MEM | tot 7.6G | free 6.0G | cache 244.6M | buff 13.0M
SWP | tot 4.0G | free 4.0G
PID TID CPU prio TIME aff SYS 10ms 1min Saving Command
3274 3274 0 - 1m1s814ms - 0% 4 - 100% - cron
68 68 93 0 2m51s855ms 0 100% 5 - 90% - kthreadd
...
Use case 6: Start and display the number of processes for each user
Code:
atop -au
Motivation: Tracking the number of processes for each user can help identify resource utilization patterns and detect any user-related resource constraints or abnormalities. This command provides a summary of the number of processes for each user currently running on the system.
Example output:
NUM | root | 20 | -root- |
NUM | john | 7 | -john- |
NUM | jdoe | 13 | -jdoe- |
...
Use case 7: Display help about interactive commands
Code:
atop -?
Motivation: This command displays help information about the interactive commands available within atop. It provides a list of available keyboard commands and their respective functions, allowing you to navigate and interact with the atop interface more efficiently.
Example output:
Description of interactive commands:
a .............. invert the sort order
c .............. change display settings
d .............. disk subsystem subscreen
...
Conclusion:
The ‘atop’ command is a powerful tool for monitoring system resources, analyzing process-level details, and troubleshooting performance issues in Linux. With its various command line options, it provides a flexible and comprehensive view of system metrics, making it a valuable tool for system administrators and performance analysts.