Operating System - HP-UX
1748336 Members
3794 Online
108762 Solutions
New Discussion юеВ

Re: percent cpu via ps auxw (berkely syntax)

 
SOLVED
Go to solution
Jim Booker
Advisor

percent cpu via ps auxw (berkely syntax)

I am new to hpux. I am used to being able to use ps auxw (berkely syntax) primarily for
pulling off the %cpu column. Does anyone know how to get this info, and I don't want to use "top". I need to be able to gather this data from a script.

Thanks - Jim
4 REPLIES 4
Christopher McCray_1
Honored Contributor

Re: percent cpu via ps auxw (berkely syntax)

I think you'll like the ps -efl command, or just ps -l. Good luck.

Chris
It wasn't me!!!!
James R. Ferguson
Acclaimed Contributor
Solution

Re: percent cpu via ps auxw (berkely syntax)

Hi Jim:

Try using the UNIX95 option of the 'ps' command like this:

# UNIX95= ps -e -o pcpu -o ruser -o args|sort -nr|grep -v %CPU|head -10

This will give the top-10 highest %CPU entries. All processes are selected; the percentage CPU; login name and command line are reported, sorted by descending CPU utilization.

Note that there is a space (blank) after 'UNIX95' before the 'ps' command. Thus, the UNIX95 variable is used *only* for the 'ps' command and no other.

See the man pages for 'ps' for more information.

Regards!

...JRF...

Re: percent cpu via ps auxw (berkely syntax)

James,
When I run your command, I get the first 10 processes. Not the top 10 for cpu usage.
Bill Hassell
Honored Contributor

Re: percent cpu via ps auxw (berkely syntax)

The percentage CPU usage is only measured during the most recen scheduling interval and is not a useful measurement of the cumulative percentage of CPU across all processes. ps has no history and is a simple snapshot once through the process tables.

A better choice is to sort the process by accumulated CPU time as in:

UNIX95= ps -eo time,ruser,args | sort | more

To better see the relationship of all processes to each other, you can use Glance or top (Glance is much more useful). You can sort the interesting processes by CPU usage.


Bill Hassell, sysadmin