Tutorial on Figuring Out Your Server: Processes

Who
Tech Articles
This tutorial has examples for four versions of UNIX: Linux, Oracle’s Solaris, Apple’s Macintosh OS X and IBM’s AIX
What is This Computer Up To?
At this point, you have some idea about the server and about your configuration. You may now want to know what’s running on the server.

Using ps –aux to see your top processes
You may be familiar with the ps command. If you use ps –aux, you can see memory and CPU usage of the individual processes.

Linux:
penguin [1]> ps –aux | more
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1524 476 ? S Jul16 0:07 init
root 2 0.0 0.0 0 0 ? SW Jul16 0:00 [migration/0]
root 3 0.0 0.0 0 0 ? SW Jul16 0:00 [migration/1]
root 4 0.0 0.0 0 0 ? SW Jul16 0:00 [migration/2]
root 5 0.0 0.0 0 0 ? SW Jul16 0:00 [migration/3]
root 6 0.0 0.0 0 0 ? SW Jul16 0:00 [keventd]
root 7 0.0 0.0 0 0 ? SWN Jul16 0:00 [ksoftirqd/0]
root 8 0.0 0.0 0 0 ? SWN Jul16 0:00 [ksoftirqd/1]
root 9 0.0 0.0 0 0 ? SWN Jul16 0:00 [ksoftirqd/2]
root 10 0.0 0.0 0 0 ? SWN Jul16 0:00 [ksoftirqd/3]
root 13 0.0 0.0 0 0 ? SW Jul16 0:00 [bdflush]

Solaris:
paloalto [1]> /usr/ucb/ps –aux | more
USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND
nbkginn 5514 28.8 0.2 2680 2392 pts/47 O 11:08:22 960:27 bash
root 3 0.9 0.0 0 0 ? S Jul 18 25:49 fsflush
root 5760 0.8 0.1 3312 1560 ? S Jul 18 10:01 ssh-agent
root 27303 0.7 0.2 3512 2864 pts/22 S 06:33:30 0:00 /usr/local/bin/ssh
root 27315 0.7 0.2 3504 3408 pts/39 O 06:33:30 0:00 /usr/ucb/ps -aux
root 1929 0.5 2.77577653936 ? R Jul 18 113:51 /petetools/tivoli/
root 27286 0.5 0.2 3944 2968 ? R 06:33:29 0:00 /opt/ssh2/bin/ssh2
root 27313 0.4 0.2 3944 2968 ? R 06:33:30 0:00 ssh endicott
root 1770 0.4 0.91743216376 ? O Jul 18 15:20 [PTAgent] /opt/Ne

In Solaris there are two versions of the ps command and you need to use the full path with
the aux option:
/usr/ucb/ps –aux

This is due to some historical reasons. Briefly, the /usr/ucb directory holds University of California Berkeley versions of various binaries.

OS X:
cupertino [1]> ps –aux | more
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
petertam 130 4.5 26.7 395068 139736 ?? S Sun12PM 53:56.14 /
Applications/WordsWords
petertam 147 0.1 5.3 209424 27548 ?? S Mon03PM 35:01.39 /
Applications/iTunes.app

Two of the top lines from my Mac OS X laptop are shown. You can see that my (fictitious)
WordsWords application is using 26.7% of the laptop’s memory, and iTunes is using 5.3%.

AIX:
endicott[1]> ps –aux | more
UID PID TTY TIME CMD
10782 31310 pts/0 0:00 ksh
10782 80526 pts/0 0:00 ps

Note that you can use awk to display only those columns you are interested in.
ps -aux | awk ' { print $1,$2,$3,$4,$8,$11} ' | more

See the top processes with top
One of the best ways to get process information from various UNIX operating systems is with
the top command (if you use AIX, you will use topas instead of top). In the examples, below,
only the first few lines of top output is shown.

Linux:
penguin [1]> top
06:35:38 up 3 days, 17:42, 1 user, load average: 0.00, 0.02, 0.06
284 processes: 283 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 0.0% 0.0% 0.6% 0.0% 0.0% 0.0% 99.1%
cpu00 0.0% 0.0% 0.0% 0.0% 0.1% 0.0% 99.8%
cpu01 0.0% 0.0% 0.0% 0.0% 0.0% 0.0% 100.0%
cpu02 0.3% 0.0% 1.7% 0.0% 0.0% 0.0% 97.8%
cpu03 0.0% 0.0% 0.9% 0.0% 0.0% 0.1% 98.8%
Mem: 2565868k av, 1790812k used, 775056k free, 0k shrd, 112008k buff
1505964k actv, 142704k in_d, 248k in_c
Swap: 4192956k av, 475772k used, 3717184k free 311360k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
2141 root 15 0 11540 2880 1716 S 0.4 0.1 41:04 0 gasd
23441 dsadmin 15 0 3036 2672 1992 S 0.1 0.1 4:17 1 engined
1 root 15 0 508 476 448 S 0.0 0.0 0:07 3 init
2 root RT 0 0 0 0 SW 0.0 0.0 0:00 0 migration/0

Solaris:
paloalto [1]> top
load averages: 2.07, 2.94, 2.65 06:37:09
169 processes: 167 sleeping, 2 on cpu
CPU states: 49.4% idle, 21.0% user, 29.6% kernel, 0.0% iowait, 0.0% swap
Memory: 2048M real, 611M free, 1057M swap in use, 2505M swap free
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
5514 nbkginn 1 0 0 2680K 2392K cpu/0 963:05 49.28% bash
1929 root 19 59 0 74M 53M sleep 114:01 1.49% java
1770 root 3 58 0 17M 16M sleep 15:21 0.14% gasd
26068 root 1 58 0 4120K 2800K sleep 0:05 0.14% sshd2
2698 nbk6v7b 1 58 0 2368K 1992K cpu/2 0:00 0.12% top
19687 sybase 11 58 0 808M 800M sleep 5:07 0.06% dataserver
627 root 6 8 0 4208K 3520K sleep 3:27 0.03% automountd
567 root 1 58 0 2416K 1416K sleep 0:11 0.01% rpcbind
21056 nbk6v7b 1 49 0 1888K 1448K sleep 0:00 0.01% ksh
5760 root 1 58 0 3312K 1560K sleep 10:03 0.01% ssh-agent

OS X:
cupertino [1]> top
Processes: 74 total, 2 running, 72 sleeping... 231 threads 15:15:36
Load Avg: 0.56, 0.44, 0.36 CPU usage: 8.0% user, 11.5% sys, 80.5% idle
SharedLibs: num = 213, resident = 31.6M code, 3.45M data, 6.41M LinkEdit
MemRegions: num = 9958, resident = 173M + 7.16M private, 166M shared
PhysMem: 84.7M wired, 266M active, 153M inactive, 504M used, 7.48M free
VM: 5.82G + 119M 187628(0) pageins, 114915(0) pageouts
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
6707 top 8.8% 0:03.47 1 18 22 792K 300K 1.22M 27.0M
6706 mdimport 0.0% 0:00.24 4 65 102 1.06M 2.60M 3.10M 49.5M
6632 lookupd 0.0% 0:00.10 2 34 38 368K 700K 1.13M 28.5M
6517 less 0.0% 0:00.01 1 13 18 140K 328K 484K 26.7M
6514 sh 0.0% 0:00.00 1 8 16 76K 692K 380K 27.2M
6513 sh 0.0% 0:00.00 1 13 16 72K 692K 568K 27.2M
6512 man 0.0% 0:00.02 1 13 16 164K 264K 448K 26.7M
5580 Microsoft 2.7% 45:39.34 8 129 794 61.7M 69.2M 106M 305M

AIX:
endicott[1]> topas
Topas Monitor for host: endicott EVENTS/QUEUES FILE/TTY
Thu Jul 20 06:39:10 2006 Interval: 2 Cswitch 177 Readch 73
Syscall 101 Writech 188
Kernel 0.4 |# | Reads 1 Rawin 0
User 0.0 | | Writes 1 Ttyout 72
Wait 0.0 | | Forks 0 Igets 0
Idle 99.6 |############################| Execs 0 Namei 4
Runqueue 0.0 Dirblk 0
Network KBPS I-Pack O-Pack KB-In KB-Out Waitqueue 0.0
en2 57.9 150.0 1.0 57.7 0.2
lo0 0.0 0.0 0.0 0.0 0.0 PAGING MEMORY
Faults 1 Real,MB 15935
Disk Busy% KBPS TPS KB-Read KB-Writ Steals 0 % Comp 5.9
hdisk1 0.0 0.0 0.0 0.0 0.0 PgspIn 0 % Noncomp 51.2
hdisk8 0.0 0.0 0.0 0.0 0.0 PgspOut 0 % Client 0.5
hdisk10 0.0 0.0 0.0 0.0 0.0 PageIn 0
hdisk13 0.0 0.0 0.0 0.0 0.0 PageOut 0 PAGING SPACE
Sios 0 Size,MB 2048
Name PID CPU% PgSp Owner % Used 0.6
gasd 31976 0.1 1.3 root NFS (calls/sec) % Free 99.3
topas 80570 0.1 1.6 nbk6v7b ServerV2 0
syncd 20682 0.0 0.6 root ClientV2 0 Press:
lrud 17286 0.0 0.0 root ServerV3 0 "h" for help
getty 35900 0.0 0.5 root ClientV3 0 "q" to quit
    

Suggestions for Future Learning
This tutorial is excerpted from UNIX For Application Support Staff Chapter 1. The historical reasons for two different version of ps are explained in Appendix 3



Tutorial Contents



Name Service queries with DNS and NIS



What Is My Server’s Configuration ?

Hardware Information : CPU and Memory

Environmental Variables : Your Configuration


Disk Usage  and Listing Directory Contents

Who Else  is Logged in?


Who
Tech Articles