Operating System - HP-UX
1837143 Members
2375 Online
110112 Solutions
New Discussion

cpu usage with UNIX95= ps -ex -o pcpu,pid,ruser,comm

 
MattJ123
Frequent Advisor

cpu usage with UNIX95= ps -ex -o pcpu,pid,ruser,comm

Hey All,

I'm using:
UNIX95= ps -ex -o pcpu,pid,ruser,comm

I understand that pcpu is the percentage of cpu power used recently but I'm unclear if this works across multiple cpu's.

For example, I want to measure current cpu usage:
ps -ex -o pcpu,pid,ruser,comm | awk '{x += $1} END {print x}'

Is it possible that this could yield greater than 100% on a 4 cpu system? Is there a better way of checking the current state of cpu?

top(1) may not work because I'd like this to be in a script, not interactive.

Any suggestions?
3 REPLIES 3
MattJ123
Frequent Advisor

Re: cpu usage with UNIX95= ps -ex -o pcpu,pid,ruser,comm

my example was wrong, let me clarify:
ps -ex -o pcpu,pid,ruser,comm | awk '{x += $1} END {print x}'
should read
UNIX95= ps -ex -o pcpu,pid,ruser,comm | awk '{x += $1} END {print x}'

MattJ123
Frequent Advisor

Re: cpu usage with UNIX95= ps -ex -o pcpu,pid,ruser,comm

i guess i could have rtfm a little closer:
top -f /tmp/test.txt

output to filename.

thanks anyway!
MattJ123
Frequent Advisor

Re: cpu usage with UNIX95= ps -ex -o pcpu,pid,ruser,comm

.