Operating System - HP-UX
1832585 Members
3396 Online
110043 Solutions
New Discussion

Percent cpu utilization per process

 
kaushikbramesh
Advisor

Percent cpu utilization per process

Hello all,

I'm porting a ksh script written to monitor the percent cpu utilization and percent memory utilization for certain process in the process table on Tru64 Unix. This script uses ps auxw command to get the %cpu and %memory utilization for all the processe in the ps table. Is there a equivalent command I can use on HP-UX to get the %CPU utilization and %memory utilization. HP-UX version HP-UX B 11.23.

Regards
Kaushik
12 REPLIES 12
Muthukumar_5
Honored Contributor

Re: Percent cpu utilization per process

You can use,

a) top
b) UNIX95= ps -ef -o cpu,pcpu,pid,comm (cpu %)

hth.
Easy to suggest when don't know about the problem!
Alex Lavrov.
Honored Contributor

Re: Percent cpu utilization per process

I believe that what you are looking for is "ps" command.

"man ps" - for more options.


Alex
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Stephen Keane
Honored Contributor

Re: Percent cpu utilization per process

You can get %CPU, but I don't think you can get %mem.

See

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=964927

for details
Muthukumar_5
Honored Contributor

Re: Percent cpu utilization per process

I hope you can get memory size utilization with top or UNIX95 + ps command.

# UNIX95= ps -ef -o cpu,pcpu,pid,sz,vsz,comm gives that.

# glance may give (Don't know)
# openview + extract may give that too.

hth.
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor

Re: Percent cpu utilization per process

# UNIX95= ps -e -o pid,comm,pcpu|sort -krn3 and # top will be helpful to % utilization.
Also checkout some performance tools for HP-UX

http://h21007.www2.hp.com/dspp/dld/dld_DownloadsListingPage_IDX/1,2381,11169,00.html


-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
kaushikbramesh
Advisor

Re: Percent cpu utilization per process

Hi,

Using export UNIX95=true
ps ps -ef -o uid,pid,pcpu,vsz,sz,state,stime,time,comm

gives me the %CPU. I dont see any arguments to find the %MEM.


Regards
Kaushik
Muthukumar_5
Honored Contributor

Re: Percent cpu utilization per process

yes,

You can only get %CPU statistics. You can memory size utilization but not the %MEM statistics.

hth.
Easy to suggest when don't know about the problem!
Alex Lavrov.
Honored Contributor

Re: Percent cpu utilization per process

It's sz and vsz fields:

sz - The size in physical pages of the core image of the process, including text, data, and stack space. Physical page size is defined by _SC_PAGE_SIZE in the header file.

vsz - The size in kilobytes (1024 byte units) of the core image of the process.

(from man)

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
kaushikbramesh
Advisor

Re: Percent cpu utilization per process

Hello all,

Thanks for all your quick replies.
Heres a sample of what I get from ps auxw on Tru64

USER PID %CPU %MEM VSZ RSS TTY S STARTED TIME COMMAND
root 274249 20.5 1.6 73.2M 66M ?? S Mar 02 2-00:28:26 /usr/sbin/cron
kaushik 230295 0.3 0.0 11.2M 1.6M ?? S 09:41:37 0:03.35 /usr/dt/bin/dtterm -ls
root 292798 0.1 0.0 2.61M 328K pts/5 S 11:19:59 0:00.02 ksh

I extract column 3 and column 4 as a routine monitoring. If either the CPU util or the MEM util exceeds a certain limit I need to raise a trap.

The ps command indeed solves the problem of %CPU. I have not found anything in the ps man pages to give me the %MEM per process.

Thanks and regards
Kaushik
Arunvijai_4
Honored Contributor

Re: Percent cpu utilization per process

Hi, You may need to look at this page for more information,

http://www.circle4.com/jaqui/papers/cmgunixp.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: Percent cpu utilization per process

Tru64 is support %MEM with pmem field.
http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V40G_HTML/MAN/MAN1/0287____.HTM

hth
Easy to suggest when don't know about the problem!
Alex Lavrov.
Honored Contributor

Re: Percent cpu utilization per process

Well, if you want % value, you can alsways calculate it.

(proc mem / total mem) * 100

Alex.
I don't give a damn for a man that can only spell a word one way. (M. Twain)