To monitor system resource usage over a period of time using atop
, you can follow these steps:
-
Install
atop
if it's not already installed:On many Linux distributions, you can install
atop
using your package manager. For example, on Ubuntu or Debian, you can use:bashsudo apt-get install atop
On CentOS or Red Hat:
bashsudo yum install atop
-
Start the
atop
service:Once
atop
is installed, you can start it by running:bashsudo systemctl start atop
If you want it to start on boot:
bashsudo systemctl enable atop
-
Open
atop
to view real-time data:To view real-time system resource usage, simply run:
bashatop
This will open an interactive interface showing various metrics.
-
Navigate the
atop
interface:- Use the arrow keys to navigate through different metrics.
- Press
t
to toggle between various views (CPU, memory, disk, etc.). - Press
h
for help andq
to quit.
-
Record Data to a File:
To record data over a period of time, you can run
atop
in daemon mode and save the output to a log file:bashsudo atop -a -w /path/to/save/logfile 600
-a
stands for archive mode (daemon mode).-w
specifies the path to the log file.600
indicates the interval in seconds (in this example, it's set to 10 minutes).
The above command will record data to the specified log file in 10-minute intervals.
-
View Recorded Data:
You can view the recorded data by running:
bashatop -r /path/to/save/logfile
This allows you to view historical data.
-
Exiting the
atop
Interface:To exit the
atop
interface, pressq
.
Remember to replace /path/to/save/logfile
it with the actual path where you want to save the log file.
By using the atop
utility, you can gather valuable insights into system resource usage over time, which can be helpful for troubleshooting and optimizing system performance.