Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Getting CPU usage % by program or shell ?
@ 1998-07-20  4:00 JKChung
  1998-07-20  4:00 ` Mark Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: JKChung @ 1998-07-20  4:00 UTC (permalink / raw)



Hi,

I am using OSF/1 4.0b in Alpha 4100 and need to get
CPU usage % as a return value by program or shell. 
How do I do this? Thank you. 

 



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Getting CPU usage % by program or shell ?
  1998-07-20  4:00 Getting CPU usage % by program or shell ? JKChung
@ 1998-07-20  4:00 ` Mark Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Taylor @ 1998-07-20  4:00 UTC (permalink / raw)


JKChung (onions@doosan.com) wrote:

: Hi,

: I am using OSF/1 4.0b in Alpha 4100 and need to get
: CPU usage % as a return value by program or shell. 
: How do I do this? Thank you. 

If you like ugly C-shell scripts you could do something like this: 

  alias tosec awk -F: "'\\
    {mult=1; for (i=NF;i>0;i--) {sec += "\$"i * mult; mult *= 60} print sec }'"
  set cpu     = `ps -p $pid -otime  | tail -1 | tosec` 
  set elapsed = `ps -p $pid -oetime | tail -1 | tosec` 
  @ percent = ( 100 * $cpu ) / $elapsed

(this is over the lifetime of the process, not current usage a la top).

Mark

---------------------------------------------------------------------------
| Mark Taylor                       Institute of Astronomy, Cambridge, UK |
| mbt@ast.cam.ac.uk    http://dougal.chm.bris.ac.uk/~mbt/    01223 337535 |
---------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-07-20  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-07-20  4:00 Getting CPU usage % by program or shell ? JKChung
1998-07-20  4:00 ` Mark Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox