1832592 Members
2913 Online
110043 Solutions
New Discussion

Top process

 
Sathish_3
Occasional Contributor

Top process

Hey,

In my application, I have to get a list of the top 10 processes and their following values:-
NAME,PID,PPID,%CPU,REAL UID,PRI,STARTTIME,USERTIME,EFF.UID,EFF.GID,STATUS,SOCK.REQ.RECVD,SOCK.REQ.SENT,SIG.RECVD,RPAGES FOR MM,VPAGES FOR MM,RPAGES FOR IO,VPAGES FOR IO

Anybody know how to retrieve these values in a simple manner(i.e. using the command top with any options) ?

Regards,
Sathish
5 REPLIES 5
Geoff Wild
Honored Contributor

Re: Top process

This might help a bit:

#!/bin/sh
# memtop - show top memory users and pid
# VSZ is in KB
echo "VSZ(KB) PID RUSER COMMAND"
UNIX95= ps -e -o 'vsz pid ruser args' |sort -nr|head -30

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
RAC_1
Honored Contributor

Re: Top process

The XPG4 conformance - UNIX95 can get some values. Also ps -efl|grep process will also give information required.

man ps, checl XPG4 conformance details.

UNIX95= ps -ef -C "process_name" -o "vsz,arg,ruser,stime,time" Will give
memory used by process - vsz
Arguments - arg
ruser - owner of the process
stime - start time(if more than 24 hrs, just the date)
time - time used. There are lot of options. check man page of ps

For information on syscalls made by process, sockets, you may use tusc tool(trace unix system calls)
You can get tusc at http://hpux.connect.uk.of

tusc -vfp "process_id"
lsof tool(list open files) will also give some details.

lsof "process_id"

Anil
There is no substitute to HARDWORK
Sridhar Bhaskarla
Honored Contributor

Re: Top process

Hi Sathish,

With 'top' you can use -n option to display the number of processes you want them to appear. Use -f option to redirect it to a file. However, you will not be able to get all these stats with top.

You can use XPG4 version of 'ps' to get some more of the ones you want.

For ex.,

UNIX95= ps -e -o 'pcpu pid ppid args' |sort -n

will sort the output by percentage CPU. change the first field to whatever you want to get sorted. Again, you may not get all the stats that you need from ps.

Look at the man pages of top and ps on what you can do with them.

Stats related to SOCKETS are to be obtained from netstat which may have to be done seperately but you won't get them on per process basis.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Franky_1
Respected Contributor

Re: Top process

Hi,

the "top" command implies the -n option for displaying only n lines

HTH

Franky
Don't worry be happy
Sathish_3
Occasional Contributor

Re: Top process


Thanks for ur suggestions Sri, Franky, Rac and Geoff

I've got all but the below information:
USERTIME
STATUS
SOCK.REQ.RECVD
SOCK.REQ.SENT
SIG.RECVD
RPAGES FOR MM
VPAGES FOR MM
RPAGES FOR IO
VPAGES FOR IO

Kindly share from your knowledge.

TIA,
Sathish