*BSD News Article 30049


Return to BSD News archive

Xref: sserve comp.unix.programmer:16768 comp.unix.misc:12226 comp.unix.questions:48937 comp.unix.aix:37132 comp.unix.bsd:13848
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!vixen.cso.uiuc.edu!rasputin.ncsa.uiuc.edu!libor
From: libor@rasputin.ncsa.uiuc.edu (Libor Michalek)
Newsgroups: comp.unix.programmer,comp.unix.misc,comp.unix.questions,comp.unix.aix,comp.unix.bsd
Subject: Re: %CPU usage for a process ?
Date: 5 May 1994 02:42:22 GMT
Organization: University of Illinois at Urbana
Lines: 21
Distribution: world
Message-ID: <2q9mee$jpe@vixen.cso.uiuc.edu>
References: <2q75oj$s1c@vixen.cso.uiuc.edu> <CpAqxF.1w3E@austin.ibm.com>
NNTP-Posting-Host: rasputin.ncsa.uiuc.edu

In article <CpAqxF.1w3E@austin.ibm.com>, accapadi@austin.ibm.com (Matt Accapadi) writes:
|> I must be missing something.  How about  ps -eF "%c %u %p %C"|sort -rn +3

Sorry I wasn't specific enough. What I meant was... how do you do this in a
C program (i.e. using the kernals process tables to find usful information
from which %CPU can be calculated.), In otherwords: How does the ps command
do this? Sorry about the confusion.

-Libor

|> In article <2q75oj$s1c@vixen.cso.uiuc.edu>,
|> Libor Michalek <libor@rasputin.ncsa.uiuc.edu> wrote:
|> >  I was wondering if anyone knows how to calculate %CPU usage for a process.
|> >I know how to get information from the kernals memory, but the kernal does
|> >NOT keep %CPU usage for a process (altough it does keep CPU time for a 
|> >process), so I assume that you use some of the fields from the process table
|> >to calculate this information. So does any one know how to do this 
|> >calculation??? I don't care which unix you can help me with since the
|> >process table for most unices are pretty similar, and I'm far too familiar
|> >with alot of them :-) but if you really want to pick one heres a list of
|> >OS's that I'll need the information for: