EC2 Ops & Resource Monitoring Guide

In this guide, we’ll cover system resource monitoring and operational checks for our t3a.large EC2 instance. This instance is running Ubuntu 22.04.5 LTS and comes with:

  1. 2 vCPUs
  2. 8 Memory (GiB)

Find more about the instance details here: https://aws.amazon.com/ec2/instance-types/t3/.

System Resource Usage

CPU & Memory

Real-Time CPU Stats

To check live CPU and memory usage, run the following command:

htop

You will see something similar to the image below:

  1. CPU Usage (First 2 Rows)

    • Displays each CPU core’s usage as a horizontal bar.
    • Color codes:
      • Green → Normal processes
      • Blue → Low-priority processes (nice value > 0)
      • Red → Kernel processes
      • Orange → IRQ (interrupt) processes
  2. Memory Usage (3rd Row)

    • Shows the total RAM usage.
    • Color codes:
      • Green → Used by processes
      • Blue → Buffers
      • Yellow → Cached memory
  3. High swap usage may indicate insufficient RAM.

  4. Press F6 or click the F6 SortBy button in the footer to sort processes by resource usage.

3. RESOURCES/Images/Screenshot 2025-03-17 at 11.58.38 PM.png

Historical CPU Load

To check the historical CPU load, run the following command:

uptime

You’ll see output similar to:

 03:05:14 up 15 days, 51 min,  1 user,  load average: 1.13, 0.67, 0.53

Memory

Real-Time Memory Stats

To view real-time memory usage, run the following command:

free -h

You’ll see output similar to:

total        used        free      shared  buff/cache   available
7.7Gi       3.9Gi       548Mi        21Mi       3.3Gi       3.5Gi

If the available memory is low, adding new services may lead to performance degradation or swapping.

Disk

To check disk usage, run the following command:

df -h

You’ll see output similar to:

Filesystem       Size  Used Avail Use% Mounted on
/dev/root         49G   30G   19G  61% /

If Use% is greater than 80%, you may run into storage issues when deploying or running new services.

Ports Availability

To check if a specific port is in use, run the following command:

sudo lsof -i -P -n | grep <PORT_NUMBER>

For example, to check if Jenkins is running on port 8090:

sudo lsof -i -P -n | grep 8090

This will list any processes currently using the specified port, helping you avoid conflicts when deploying new services.