Installing the Atop tool in Amazon Linux 2023 for Monitoring

Monitoring system resources using the CLI on Amazon Linux 2023 can be quite easy with the help of a tool called “Atop“. It is a command line tool used to get the details of processes, network activities, and disk usage right on the terminal. Most of the Linux distros offer this tool package from their system default repository, and so does the Al2023. As Amazon Linux is mostly used as a server without a graphical interface, Atop will be the right tool to quickly know about the system resource consumption.

Command to install Atop on Amazon Linux 2023

Step 1: Connect AL2023 Terminal

First, we need to access the terminal of Amazon Linux 2023 to issue the commands required to install any RPM packages available for Al2023. So, either go to the EC2 Dashboard and connect your Instance from there or use SSH from the local terminal.

Just replace the key.pem with your actual key file and amazonlinux-user@your-instance-ip with your instance’s user and IP address, if you are using the local terminal to connect the Al2023 using SSH protocol.

ssh -i path-to-key.pem amazonlinux-user@your-instance-ip

Step 2: Update Package Repositories

Start with a system update right after having the access to AL2023 terminal, it will rebuild the DNF package list and install the updates:

sudo dnf update 

Step 3: Install Atop on Amazon Linux 2023

Finally, use the DNF along with the Atop as a package name to install it on AL2023, nothing complicated.

sudo dnf install atop
installation command atop Amazon linuxn 2023

A few examples to use Atop

Once the installation is completed we can start using this monitoring tool, here are some examples to learn how to use Atop.

Example 1: Monitoring System Activity

After completing the installation, to start the atop and see the system activity to monitor in real-time, we just need to type its name in our command terminal.

sudo atop

The CLI text-based dashboard of Atop will show various information such as CPU utilization along with the consumption of Memory, Disk, Network, and the list of all processes along with PID. We can press ‘t’ on the keyboard to toggle between various views of Atop.

Atop amazon linux 2023 install and  start command

If we press the “h” key it will open the help section and give the details about the various flags, which means options to control the functions of Atop.

Display mode:

'B' - show bar graphs for system utilization (toggle)

Information in text mode for active processes:

'g' - generic info (default)
'm' - memory details
'd' - disk details
'n' - network details
'X' - cgroups v2 details
's' - scheduling and thread-group info
'e' - GPU details
'v' - various info (ppid, user/group, date/time, status, exitcode)
'c' - full command line per process
'o' - use own output line definition

Sort list of processes in order of:

'C' - cpu activity
'M' - memory consumption
'D' - disk activity
'N' - network activity
'E' - GPU activity
'A' - most active system resource (auto mode)

Accumulated figures:

'u' - total resource consumption per user
'p' - total resource consumption per program (i.e. same process name)
'j' - total resource consumption per container

Process selections (keys shown in header line):

'U' - focus on specific user name(regular expression)
'P' - focus on specific program name(regular expression)
'J' - focus on specific container id (CID)
'/' - focus on specific command line string (regular expression)
'I' - focus on specific process id (PID)
'Q' - focus on specific process/thread state(s)

Press q (leave help), space (next page), Enter (next line) or select key...

Example 2: Viewing CPU Usage

In the first example, we have seen all major system activity details, however, what if we want to go for some particular information? Let’s see the command to use atop to monitor CPU usage over time. Well, in the same previously used command, we have used previously just add the ‘-c‘ option. This command will show CPU-related statistics, including individual CPU utilization, context switches, and load averages.

 sudo atop -c

 

Viewing CPU Usage

Example 3: Analyzing Disk Activity

We can check or monitor the disk utilization, I/O rates, and disk transfers per process on Amazon Linux by using the “-d” flag with the atop command:

sudo atop -d
disk usage monitor

Example 4: Monitoring Network Activity

To monitor network activity using atop, run the given command it will provide the network-related statistics, including network interface usage, TCP and UDP traffic, and connections per process.

sudo atop -n

 

Monitoring Network Activity

You may get an error while running this command that is “kernel module ‘netatop’ not active or no root privs; request ignored!”. If you have such an error then follow the given commands to install the Netatop module in Amazon Linux.

sudo dnf install kernel-devel zlib-devel
wget https://www.atoptool.nl/download/netatop-3.1.tar.gz
tar -xvf netatop-3.1.tar.gz
cd netatop-3.1
make 
sudo make install 

After installing netatop, we can run the “atop -n” command to monitor network activity.

 

Example 5: Monitoring Memory Usage

Now, if we want atop to show only memory usage consumption and the amount of free RAM available on our Amazon Linux including the process occupying the current memory, we can use the “-m” option with the atop command:

sudo atop -m
Atop Monitoring Memory Usage

Example 6: Analyzing Process Activity

Another option to use is “-p“, it will display the individual process activity happening on Amazon Linux sorted by the resource consumption.

sudo atop -p
atop command Analyzing Process Activity

 

Example 7: Monitoring Specific Process Activity

Last but not least because yet there are many commands that we can use with Atop to get the customized monitoring report, however, if you want to get the activity details of some particular process then again with the “-p” option just add the PID of that process.

Replace [PID] with the actual process ID of the process you want to monitor.

sudo atop -p [PID]

 

 

Conclusion:

We have seen the installation of aTop on Amazon Linux itself not a difficult task however learning to use it can be a little bit tricky for new users. Nevertheless, we already have discussed the key commands that we can use to get the details of our AL2023 server resource usage in real-time whether it is memory usage, analyzing process activity, or generating detailed reports, atop can be handy in all these.

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.