[geeks] getting CPU status in FreeBSD

Charles Shannon Hendrix shannon at widomaker.com
Thu Sep 13 15:09:44 CDT 2007


Thu, 13 Sep 2007 @ 15:36 -0400, Sridhar Ayengar said:

> Charles Shannon Hendrix wrote:
> >>> Does anyone know of a decent routine to get the CPU stats under FreeBSD?
> >>>
> >>> I basically just want a function that returns 0-100 for each CPU in the
> >>> system so I can print the results to an LCD.
> >>>
> >>> I'm trying to dig this information out of top sources, but it's a real
> >>> hairball, so I'm looking for something easier if I can find it.
> >> I don't suppose you could write a little awk-ism to read it right out of 
> >> top's console output?
> > 
> > No, this is an embedded LCD in an appliance system.
> 
> I don't know if that's relevant.  Just interact with the top process 
> using pipes.
> 
> Or do you not have access to awk?

Yes, but that's too heavy to do inside a realtime event loop, and it
would be complicated to maintain a copy of another program running just
to read strings from it.

It needs to be a fast C function.

I'm almost done, so I guess it doesn't matter.

I thought maybe someone knew of some routines already written.  I'm kind
of surprised there are not.

Well, there will be soon... :)


-- 
shannon           | There are nowadays professors of philosophy, but not
                  | philosophers. 



More information about the geeks mailing list