*BSD News Article 30422


Return to BSD News archive

Xref: sserve comp.unix.programmer:17016 comp.unix.misc:12352 comp.unix.questions:49402 comp.unix.aix:37651 comp.unix.bsd:13950
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!howland.reston.ans.net!EU.net!sunic!ericom!erinews.ericsson.se!usenet
From: etxmesa@eos.ericsson.se (Michael Salmon)
Newsgroups: comp.unix.programmer,comp.unix.misc,comp.unix.questions,comp.unix.aix,comp.unix.bsd
Subject: Re: %CPU usage for a process ?
Date: 6 May 1994 09:38:07 GMT
Organization: Ericsson Telecom AB
Lines: 26
Sender: etxmesa@eos6c02.ericsson.se (Michael Salmon)
Distribution: world
Message-ID: <2qd35v$6j@erinews.ericsson.se>
References: <2q75oj$s1c@vixen.cso.uiuc.edu> <CpAqxF.1w3E@austin.ibm.com> <2q9mee$jpe@vixen.cso.uiuc.edu>
Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
NNTP-Posting-Host: eos6c02.ericsson.se

In article <2q9mee$jpe@vixen.cso.uiuc.edu>
libor@rasputin.ncsa.uiuc.edu (Libor Michalek) writes:
|> 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.

I don't think that there is a standard way of doing this so you must
UTSL. Fetch a ps that works for your system and study it. Alternatives
are top and GNU make. Probably the easiest and most portable way is to
use ps to do the work.

-- 

Michael Salmon

#include	<standard.disclaimer>
#include	<witty.saying>
#include	<fancy.pseudo.graphics>

Ericsson Telecom AB
Stockholm