天天看點

How to Check Swap and Memory Usage Live via the 'top' Command on Oracle Linux 5, 6, 7, and 8

How to Check Swap and Memory Usage Live via the 'top' Command on Oracle Linux 5, 6, 7, and 8. (文檔 ID 2422888.1)

APPLIES TO:

Oracle Cloud Infrastructure - Version N/A and later

Linux OS - Version Oracle Linux 6.0 and later

Linux x86-64

GOAL

View the system wide swap and memory usage on an Oracle Linux server via the top command to identify the highest consumers.

If you would rather review the swap usage by a specific process review the document below:

How To Check Swap Usage of Each Processes (Doc ID 1931980.1)

SOLUTION

 Below are the steps for Oracle Linux 5  and 6 which are the same, followed by Oracle Linux 7 and Oracle Linux 8 as they differ on newer releases:

NOTE: Performing this task will not cause any changes to top command, this is only temporary while you have your top command running. Exiting top and starting it again will reset your changes.

Oracle Linux 5 and Oracle Linux 6:

Checking swap usage:

1a. Run the TOP command:

# top

1.b: On your keyboard press the " f " key followed by " p " to add the Swap column, Hit enter.

1.c: Next upper case "O" and finally "p" sort by swap, Hit enter.

1.d: Perform your review as needed and press "q" to exit top command.

Checking memory usage:

1e. Run the TOP command:

# top

1.f: Next upper case "O" and finally "n" sort by %MEM, Hit enter.

1.g: Perform your review as needed and press "q" to exit top command.

Oracle Linux 7 and Oracle Linux 8:

Checking swap usage:

2a. Run the TOP command:

# top

2b. On your keyboard press the " f " key and scroll down using the <down> arrow key until you have selected "SWAP" then press <Space> to select it. This should add a " * " symbol in front of it.

2c. While still selecting "SWAP"  press the <right> arrow key, which highlights the entire SWAP line, and using the <top> arrow key move it up to one of the first options (anywhere above "COMMAND").

2d. While still having "SWAP" selected, type the " s " key which will configure top to SORT by the currently selected option, in this case SWAP.

2e. Finally " q " to save the configuration changes and view the results.

2f. Perform your review as needed and press "q" again to exit top command.

Checking memory usage:

2g. Run the TOP command:

# top

2h. On your keyboard press the " f " key and scroll down using the <down> arrow key until you have selected "%MEM"

2i. While still having "%MEM" selected, type the " s " key.

2j. Finally " q " to save the configuration changes and view the results.

2k. Perform your review as needed and press "q" again to exit top command.

For more information on top options and fields review the man page. Below are a few lines from the top man page that provide some information on the memory fields and what they represent.

# man top

MEM -- Memory Usage (RES)

A task's currently used share of available physical memory.

RES -- Resident Memory Size (KiB)

The non-swapped physical memory a task is using.

SHR -- Shared Memory Size (KiB)

The amount of shared memory available to a task, not all of which is typically resident. It simply reflects memory that could be potentially shared with other processes.

SWAP -- Swapped Size (KiB)

The non-resident portion of a task's address space.

VIRT -- Virtual Memory Size (KiB)

The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.

繼續閱讀