Oracle Consulting Oracle Training Oracle Support Development
Oracle Books
SQL Server Books
IT Books
Job Interview Books
Rampant Horse Books
911 Series
Pedagogue Books

Oracle Software
Write for Rampant
Publish with Rampant
Rampant News
Rampant Authors
Rampant Staff
Oracle News
Oracle Forum
Oracle Tips
Articles by our Authors
Press Releases
SQL Server Books

Oracle 11g Books

Oracle tuning

Oracle training

Oracle support

Remote Oracle


Privacy Policy


  Oracle Tips by Burleson

Top Memory and CPU users

You may recall an earlier discussion of the ps command for
determining process status. When we specify the u option with
the ps command, columns representing the percentage of CPU
and the percentage of memory that a process is using are
displayed as represented below by columns 3 and 4.

# ps u

terry 4968 0.0 0.5 5644 1320 pts/6 S 11:21
0:00 -bash
terry 5120 0.0 0.2 3440 756 pts/6 R 11:42
0:00 ps u

We can then add options to the ps command to include all
processes, not just our own (ax) and build a complex command
to display the top CPU consumer and the top memory user

Display top CPU user

ps aux | sort -n +2 | tail -1

root 2201 0.2 3.2 36564 8464 ? S Oct17
2:18 /usr/X11R6/bin/X :0 -audit 0 -auth /var/gdm/:0.Xauth -
nolisten tcp vt7

Display top Memory user
$ ps aux | sort -n +3 | tail -1

gdm 3718 0.0 3.5 20744 9012 ? S 00:09
0:36 /usr/bin/gdmgreeter

We will discuss more about building complex commands in the
shell scripting chapter. For now, accept that commands can
redirect their output to other commands to perform a series of
operations. In the example above displaying the top memory
user we display all processes, then sort the processes in
ascending sequence using the numeric value found in column 4
(+3), then display the last value (highest) in the sorted list.

If we wanted to see the top 5 (high to low) memory users in the
system we could modify our command string as follows:

ps aux|sort -nr +3|grep -v USER|head -5

gdm 3718 0.0 3.5 20744 9012 ? S 00:09
0:37 /usr/bin/gdmgreeter
root 2201 0.2 3.2 36564 8464 ? S Oct17
2:19 /usr/X11R6/bin/X :0 -audit 0 -auth /var/gdm/:0.Xauth -
nolisten tcp vt7
xfs 1887 0.0 1.2 4996 3152 ? S Oct17
0:00 xfs -droppriv -daemon
root 2190 0.0 1.1 12664 2972 ? S Oct17
0:03 /usr/bin/gdm-binary -nodaemon
terry 3286 0.0 1.0 8296 2776 ? S Oct17
0:00 /usr/libexec/bonobo-activation-server --ac-activate --

The above book excerpt is from:

Easy Linux Commands
Working Examples of Linux Command Syntax

ISBN: 0-9759135-0-6   

Terry Clark 

Linux Oracle commands syntax poster

ION Oracle tuning software

Oracle data dictionary reference poster

Oracle Forum

BC Oracle consulting support training

BC remote Oracle DBA   



 Copyright © 1996 -2016 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation. SQL Server® is the registered trademark of Microsoft Corporation. 
Many of the designations used by computer vendors to distinguish their products are claimed as Trademarks

Hit Counter